Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 237916 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/swt/nebula/snippets/grid/GridSnippet2.java (-10 / +10 lines)
Lines 34-55 Link Here
34
34
35
    Grid grid = new Grid(shell,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
35
    Grid grid = new Grid(shell,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
36
    grid.setHeaderVisible(true);
36
    grid.setHeaderVisible(true);
37
    grid.setFooterVisible(true);
38
    grid.setRowHeaderVisible(true);
37
    GridColumn column = new GridColumn(grid,SWT.NONE);
39
    GridColumn column = new GridColumn(grid,SWT.NONE);
38
    column.setText("Column 1");
40
    column.setText("Column 1");
39
    column.setWidth(100);
41
    column.setWidth(100);
42
    column.setFooterText("Sum 1");
40
    GridColumn column2 = new GridColumn(grid,SWT.NONE);
43
    GridColumn column2 = new GridColumn(grid,SWT.NONE);
41
    column2.setText("Column 2");
44
    column2.setText("Column 2");
42
    column2.setWidth(100);
45
    column2.setWidth(100);
43
    GridItem item1 = new GridItem(grid,SWT.NONE);
46
    column2.setFooterText("Sum 2");
44
    item1.setText("First Item");
47
    
45
    item1.setText(1,"xxxxxxx");
48
    for( int i = 0; i < 50; i++ ) {
46
    GridItem item2 = new GridItem(grid,SWT.NONE);
49
        GridItem item1 = new GridItem(grid,SWT.NONE);
47
    item2.setText("This cell spans both columns");
50
        item1.setText("First Item");
48
    item1.setText(1,"xxxxxxx");
51
        item1.setText(1,"x"+i);
49
    item2.setColumnSpan(0,1);
52
    }
50
    GridItem item3 = new GridItem(grid,SWT.NONE);
51
    item3.setText("Third Item");
52
    item1.setText(1,"xxxxxxx");
53
    
53
    
54
    shell.setSize(200,200);
54
    shell.setSize(200,200);
55
    shell.open ();
55
    shell.open ();
(-)src/org/eclipse/nebula/widgets/grid/GridColumn.java (+112 lines)
Lines 11-21 Link Here
11
package org.eclipse.nebula.widgets.grid;
11
package org.eclipse.nebula.widgets.grid;
12
12
13
import org.eclipse.nebula.widgets.grid.internal.DefaultCellRenderer;
13
import org.eclipse.nebula.widgets.grid.internal.DefaultCellRenderer;
14
import org.eclipse.nebula.widgets.grid.internal.DefaultColumnFooterRenderer;
14
import org.eclipse.nebula.widgets.grid.internal.DefaultColumnHeaderRenderer;
15
import org.eclipse.nebula.widgets.grid.internal.DefaultColumnHeaderRenderer;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWTException;
16
import org.eclipse.swt.events.ControlListener;
18
import org.eclipse.swt.events.ControlListener;
17
import org.eclipse.swt.events.SelectionListener;
19
import org.eclipse.swt.events.SelectionListener;
18
import org.eclipse.swt.graphics.GC;
20
import org.eclipse.swt.graphics.GC;
21
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Point;
22
import org.eclipse.swt.graphics.Point;
20
import org.eclipse.swt.graphics.Rectangle;
23
import org.eclipse.swt.graphics.Rectangle;
21
import org.eclipse.swt.widgets.Event;
24
import org.eclipse.swt.widgets.Event;
Lines 55-60 Link Here
55
     * Header renderer.
58
     * Header renderer.
56
     */
59
     */
57
    private GridHeaderRenderer headerRenderer = new DefaultColumnHeaderRenderer();
60
    private GridHeaderRenderer headerRenderer = new DefaultColumnHeaderRenderer();
61
    
62
    private GridFooterRenderer footerRenderer = new DefaultColumnFooterRenderer();
58
63
59
    /**
64
    /**
60
     * Cell renderer.
65
     * Cell renderer.
Lines 118-123 Link Here
118
    private GridColumnGroup group;
123
    private GridColumnGroup group;
119
    
124
    
120
    private boolean checkable = true;
125
    private boolean checkable = true;
126
    
127
    private Image footerImage;
128
    
129
    private String footerText = "";
121
130
122
    /**
131
    /**
123
     * Constructs a new instance of this class given its parent (which must be a
132
     * Constructs a new instance of this class given its parent (which must be a
Lines 215-220 Link Here
215
        }
224
        }
216
225
217
        initHeaderRenderer();
226
        initHeaderRenderer();
227
        initFooterRenderer();
218
        initCellRenderer();
228
        initCellRenderer();
219
    }
229
    }
220
230
Lines 239-244 Link Here
239
    {
249
    {
240
        headerRenderer.setDisplay(getDisplay());
250
        headerRenderer.setDisplay(getDisplay());
241
    }
251
    }
252
    
253
    /**
254
     * Initialize header renderer.
255
     */
256
    private void initFooterRenderer()
257
    {
258
        footerRenderer.setDisplay(getDisplay());
259
    }
242
260
243
    /**
261
    /**
244
     * Initialize cell renderer.
262
     * Initialize cell renderer.
Lines 273-278 Link Here
273
        return headerRenderer;
291
        return headerRenderer;
274
    }
292
    }
275
293
294
    
295
    GridFooterRenderer getFooterRenderer() {
296
    	return footerRenderer;
297
    }
298
    
276
    /**
299
    /**
277
     * Returns the cell renderer.
300
     * Returns the cell renderer.
278
     * 
301
     * 
Lines 619-624 Link Here
619
        this.headerRenderer = headerRenderer;
642
        this.headerRenderer = headerRenderer;
620
        initHeaderRenderer();
643
        initHeaderRenderer();
621
    }
644
    }
645
    
646
    /**
647
     * Sets the header renderer.
648
     * 
649
     * @param footerRenderer The footerRenderer to set.
650
     * @throws org.eclipse.swt.SWTException
651
     * <ul>
652
     * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
653
     * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that
654
     * created the receiver</li>
655
     * </ul>
656
     */
657
    public void setFooterRenderer(GridFooterRenderer footerRenderer)
658
    {
659
        checkWidget();
660
        this.footerRenderer = footerRenderer;
661
        initFooterRenderer();
662
    }
622
663
623
    /**
664
    /**
624
     * Adds a listener to the list of listeners notified when the column is
665
     * Adds a listener to the list of listeners notified when the column is
Lines 1086-1089 Link Here
1086
        cellRenderer.setWordWrap(wordWrap);
1127
        cellRenderer.setWordWrap(wordWrap);
1087
        parent.redraw();
1128
        parent.redraw();
1088
    }
1129
    }
1130
    
1131
    /**
1132
     * Sets the receiver's footer image to the argument, which may be
1133
     * null indicating that no image should be displayed.
1134
     *
1135
     * @param image the image to display on the receiver (may be null)
1136
     *
1137
     * @exception IllegalArgumentException <ul>
1138
     *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> 
1139
     * </ul>
1140
     * @exception SWTException <ul>
1141
     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1142
     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1143
     * </ul>
1144
     */
1145
    public void setFooterImage (Image image) {
1146
    	checkWidget ();
1147
    	if (image != null && image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
1148
    	this.footerImage = image;
1149
    }
1150
1151
    /**
1152
     * Sets the receiver's footer text.
1153
     *
1154
     * @param string the new text
1155
     *
1156
     * @exception IllegalArgumentException <ul>
1157
     *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
1158
     * </ul>
1159
     * @exception SWTException <ul>
1160
     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1161
     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1162
     * </ul>
1163
     */
1164
    public void setFooterText (String string) {
1165
    	checkWidget ();
1166
    	if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
1167
    	this.footerText = string;
1168
    }
1169
    
1170
    /**
1171
     * Returns the receiver's footer image if it has one, or null
1172
     * if it does not.
1173
     *
1174
     * @return the receiver's image
1175
     *
1176
     * @exception SWTException <ul>
1177
     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1178
     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1179
     * </ul>
1180
     */
1181
    public Image getFooterImage () {
1182
    	checkWidget ();
1183
    	return footerImage;
1184
    }
1185
1186
    /**
1187
     * Returns the receiver's footer text, which will be an empty
1188
     * string if it has never been set.
1189
     *
1190
     * @return the receiver's text
1191
     *
1192
     * @exception SWTException <ul>
1193
     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1194
     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1195
     * </ul>
1196
     */
1197
    public String getFooterText () {
1198
    	checkWidget();
1199
    	return footerText;
1200
    }
1089
}
1201
}
(-)src/org/eclipse/nebula/widgets/grid/Grid.java (-13 / +438 lines)
Lines 16-24 Link Here
16
import java.util.List;
16
import java.util.List;
17
import java.util.Vector;
17
import java.util.Vector;
18
18
19
import org.eclipse.nebula.widgets.grid.internal.DefaultBottomLeftRenderer;
19
import org.eclipse.nebula.widgets.grid.internal.DefaultColumnGroupHeaderRenderer;
20
import org.eclipse.nebula.widgets.grid.internal.DefaultColumnGroupHeaderRenderer;
20
import org.eclipse.nebula.widgets.grid.internal.DefaultDropPointRenderer;
21
import org.eclipse.nebula.widgets.grid.internal.DefaultDropPointRenderer;
21
import org.eclipse.nebula.widgets.grid.internal.DefaultEmptyCellRenderer;
22
import org.eclipse.nebula.widgets.grid.internal.DefaultEmptyCellRenderer;
23
import org.eclipse.nebula.widgets.grid.internal.DefaultEmptyColumnFooterRenderer;
22
import org.eclipse.nebula.widgets.grid.internal.DefaultEmptyColumnHeaderRenderer;
24
import org.eclipse.nebula.widgets.grid.internal.DefaultEmptyColumnHeaderRenderer;
23
import org.eclipse.nebula.widgets.grid.internal.DefaultEmptyRowHeaderRenderer;
25
import org.eclipse.nebula.widgets.grid.internal.DefaultEmptyRowHeaderRenderer;
24
import org.eclipse.nebula.widgets.grid.internal.DefaultFocusRenderer;
26
import org.eclipse.nebula.widgets.grid.internal.DefaultFocusRenderer;
Lines 249-254 Link Here
249
     * shown.
251
     * shown.
250
     */
252
     */
251
    private IRenderer topLeftRenderer = new DefaultTopLeftRenderer();
253
    private IRenderer topLeftRenderer = new DefaultTopLeftRenderer();
254
    
255
    /**
256
     * Renderer to paint the bottom left area when row headers and column footers are shown
257
     */
258
    private IRenderer bottomLeftRenderer = new DefaultBottomLeftRenderer();
252
259
253
    /**
260
    /**
254
     * Renderer used to paint row headers.
261
     * Renderer used to paint row headers.
Lines 262-267 Link Here
262
    private IRenderer emptyColumnHeaderRenderer = new DefaultEmptyColumnHeaderRenderer();
269
    private IRenderer emptyColumnHeaderRenderer = new DefaultEmptyColumnHeaderRenderer();
263
270
264
    /**
271
    /**
272
     * Renderer used to paint empty column footers, used when the columns don't
273
     * fill the horz space.
274
     */
275
    private IRenderer emptyColumnFooterRenderer = new DefaultEmptyColumnFooterRenderer();
276
    
277
    /**
265
     * Renderer used to paint empty cells to fill horz and vert space.
278
     * Renderer used to paint empty cells to fill horz and vert space.
266
     */
279
     */
267
    private GridCellRenderer emptyCellRenderer = new DefaultEmptyCellRenderer();
280
    private GridCellRenderer emptyCellRenderer = new DefaultEmptyCellRenderer();
Lines 294-299 Link Here
294
    private boolean columnHeadersVisible = false;
307
    private boolean columnHeadersVisible = false;
295
308
296
    /**
309
    /**
310
     * Are column footers visible?
311
     */
312
    private boolean columnFootersVisible = false;
313
    
314
    /**
297
     * Type of selection behavior. Valid values are SWT.SINGLE and SWT.MULTI.
315
     * Type of selection behavior. Valid values are SWT.SINGLE and SWT.MULTI.
298
     */
316
     */
299
    private int selectionType = SWT.SINGLE;
317
    private int selectionType = SWT.SINGLE;
Lines 333-338 Link Here
333
     * Height of each column header.
351
     * Height of each column header.
334
     */
352
     */
335
    private int headerHeight = 0;
353
    private int headerHeight = 0;
354
    
355
    /**
356
     * Height of each column footer
357
     */
358
    private int footerHeight = 0;
336
359
337
    /**
360
    /**
338
     * True if mouse is hover on a column boundary and can resize the column.
361
     * True if mouse is hover on a column boundary and can resize the column.
Lines 685-692 Link Here
685
        sizingGC = new GC(this);
708
        sizingGC = new GC(this);
686
        
709
        
687
        topLeftRenderer.setDisplay(getDisplay());
710
        topLeftRenderer.setDisplay(getDisplay());
711
        bottomLeftRenderer.setDisplay(getDisplay());
688
        rowHeaderRenderer.setDisplay(getDisplay());
712
        rowHeaderRenderer.setDisplay(getDisplay());
689
        emptyColumnHeaderRenderer.setDisplay(getDisplay());
713
        emptyColumnHeaderRenderer.setDisplay(getDisplay());
714
        emptyColumnFooterRenderer.setDisplay(getDisplay());
690
        emptyCellRenderer.setDisplay(getDisplay());
715
        emptyCellRenderer.setDisplay(getDisplay());
691
        dropPointRenderer.setDisplay(getDisplay());
716
        dropPointRenderer.setDisplay(getDisplay());
692
        focusRenderer.setDisplay(getDisplay());
717
        focusRenderer.setDisplay(getDisplay());
Lines 1487-1492 Link Here
1487
    }
1512
    }
1488
1513
1489
    /**
1514
    /**
1515
     * Returns the empty column footer renderer.
1516
     * 
1517
     * @return Returns the emptyColumnFooterRenderer.
1518
     * @throws org.eclipse.swt.SWTException
1519
     * <ul>
1520
     * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1521
     * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that
1522
     * created the receiver</li>
1523
     * </ul>
1524
     */
1525
    public IRenderer getEmptyColumnFooterRenderer() {
1526
    	checkWidget();
1527
    	return emptyColumnFooterRenderer;
1528
    }
1529
    
1530
    /**
1490
     * Returns the empty row header renderer.
1531
     * Returns the empty row header renderer.
1491
     * 
1532
     * 
1492
     * @return Returns the emptyRowHeaderRenderer.
1533
     * @return Returns the emptyRowHeaderRenderer.
Lines 1575-1580 Link Here
1575
    }
1616
    }
1576
1617
1577
    /**
1618
    /**
1619
     * Returns the height of the column footers.
1620
     * 
1621
     * @return height of the column footer row
1622
     * @throws org.eclipse.swt.SWTException
1623
     * <ul>
1624
     * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1625
     * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that
1626
     * created the receiver</li>
1627
     * </ul>
1628
     */
1629
    public int getFooterHeight() {
1630
    	checkWidget();
1631
    	return footerHeight;
1632
    }
1633
    
1634
    /**
1578
     * Returns the height of the column group headers.
1635
     * Returns the height of the column group headers.
1579
     * 
1636
     * 
1580
     * @return height of column group headers
1637
     * @return height of column group headers
Lines 1610-1615 Link Here
1610
    }
1667
    }
1611
1668
1612
    /**
1669
    /**
1670
     * Returns {@code true} if the receiver's footer is visible, and {@code false} otherwise
1671
     * @return the receiver's footer's visibility state
1672
     * @throws org.eclipse.swt.SWTException
1673
     * <ul>
1674
     * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1675
     * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that
1676
     * created the receiver</li>
1677
     * </ul>
1678
     */
1679
    public boolean getFooterVisible() {
1680
    	checkWidget();
1681
    	return columnFootersVisible;
1682
    }
1683
    
1684
    /**
1613
     * Returns the item at the given, zero-relative index in the receiver.
1685
     * Returns the item at the given, zero-relative index in the receiver.
1614
     * Throws an exception if the index is out of range.
1686
     * Throws an exception if the index is out of range.
1615
     * 
1687
     * 
Lines 2660-2666 Link Here
2660
     * @return height of visible grid in pixels
2732
     * @return height of visible grid in pixels
2661
     */
2733
     */
2662
    int getVisibleGridHeight() {
2734
    int getVisibleGridHeight() {
2663
        return getClientArea().height - (columnHeadersVisible ? headerHeight : 0);
2735
        return getClientArea().height - (columnHeadersVisible ? headerHeight : 0) - (columnFootersVisible ? footerHeight : 0);
2664
    }
2736
    }
2665
2737
2666
    /**
2738
    /**
Lines 2679-2684 Link Here
2679
        checkWidget();
2751
        checkWidget();
2680
        return topLeftRenderer;
2752
        return topLeftRenderer;
2681
    }
2753
    }
2754
    
2755
    /**
2756
     * Gets the bottom left renderer.
2757
     * 
2758
     * @return Returns the bottomLeftRenderer.
2759
     * @throws org.eclipse.swt.SWTException
2760
     * <ul>
2761
     * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
2762
     * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that
2763
     * created the receiver</li>
2764
     * </ul>
2765
     */
2766
    public IRenderer getBottomLeftRenderer()
2767
    {
2768
        checkWidget();
2769
        return bottomLeftRenderer;
2770
    }
2682
2771
2683
    /**
2772
    /**
2684
     * Searches the receiver's list starting at the first column (index 0) until
2773
     * Searches the receiver's list starting at the first column (index 0) until
Lines 3269-3274 Link Here
3269
        emptyColumnHeaderRenderer.setDisplay(getDisplay());
3358
        emptyColumnHeaderRenderer.setDisplay(getDisplay());
3270
        this.emptyColumnHeaderRenderer = emptyColumnHeaderRenderer;
3359
        this.emptyColumnHeaderRenderer = emptyColumnHeaderRenderer;
3271
    }
3360
    }
3361
    
3362
    /**
3363
     * Sets the empty column footer renderer.
3364
     * 
3365
     * @param emptyColumnFooterRenderer The emptyColumnFooterRenderer to set.
3366
     * @throws org.eclipse.swt.SWTException
3367
     * <ul>
3368
     * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
3369
     * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that
3370
     * created the receiver</li>
3371
     * </ul>
3372
     */
3373
    public void setEmptyColumnFooterRenderer(IRenderer emptyColumnFooterRenderer)
3374
    {
3375
        checkWidget();
3376
        emptyColumnFooterRenderer.setDisplay(getDisplay());
3377
        this.emptyColumnFooterRenderer = emptyColumnFooterRenderer;
3378
    }
3272
3379
3273
    /**
3380
    /**
3274
     * Sets the empty row header renderer.
3381
     * Sets the empty row header renderer.
Lines 3395-3400 Link Here
3395
        this.columnHeadersVisible = show;
3502
        this.columnHeadersVisible = show;
3396
        redraw();
3503
        redraw();
3397
    }
3504
    }
3505
    
3506
    /**
3507
     * Marks the receiver's footer as visible if the argument is {@code true},
3508
     * and marks it invisible otherwise.
3509
     * 
3510
     * @param show the new visibility state
3511
     * @throws org.eclipse.swt.SWTException
3512
     * <ul>
3513
     * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
3514
     * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that
3515
     * created the receiver</li>
3516
     * </ul>
3517
     */
3518
    public void setFooterVisible(boolean show)
3519
    {
3520
        checkWidget();
3521
        this.columnFootersVisible = show;
3522
        redraw();
3523
    }
3398
3524
3399
    /**
3525
    /**
3400
     * Sets the line color.
3526
     * Sets the line color.
Lines 3798-3803 Link Here
3798
        topLeftRenderer.setDisplay(getDisplay());
3924
        topLeftRenderer.setDisplay(getDisplay());
3799
        this.topLeftRenderer = topLeftRenderer;
3925
        this.topLeftRenderer = topLeftRenderer;
3800
    }
3926
    }
3927
    
3928
    /**
3929
     * Sets the bottom left renderer.
3930
     * 
3931
     * @param bottomLeftRenderer The topLeftRenderer to set.
3932
     * @throws org.eclipse.swt.SWTException
3933
     * <ul>
3934
     * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
3935
     * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that
3936
     * created the receiver</li>
3937
     * </ul>
3938
     */
3939
    public void setBottomLeftRenderer(IRenderer bottomLeftRenderer)
3940
    {
3941
        checkWidget();
3942
        bottomLeftRenderer.setDisplay(getDisplay());
3943
        this.bottomLeftRenderer = bottomLeftRenderer;
3944
    }
3801
3945
3802
    /**
3946
    /**
3803
     * Shows the column. If the column is already showing in the receiver, this
3947
     * Shows the column. If the column is already showing in the receiver, this
Lines 4117-4122 Link Here
4117
        headerHeight = colHeaderHeight + groupHeight;
4261
        headerHeight = colHeaderHeight + groupHeight;
4118
        groupHeaderHeight = groupHeight;
4262
        groupHeaderHeight = groupHeight;
4119
    }
4263
    }
4264
    
4265
    private void computeFooterHeight(GC gc)
4266
    {
4267
4268
        int colFooterHeight = 0;
4269
        for (Iterator columnsIterator = columns.iterator(); columnsIterator.hasNext(); )
4270
        {
4271
            GridColumn column = (GridColumn) columnsIterator.next();
4272
            colFooterHeight = Math
4273
                .max(column.getFooterRenderer().computeSize(gc, column.getWidth(), SWT.DEFAULT,
4274
                                                            column).y, colFooterHeight);
4275
        }
4276
4277
        footerHeight = colFooterHeight;
4278
    }
4120
4279
4121
    /**
4280
    /**
4122
     * Returns the computed default item height. Currently this method just gets the
4281
     * Returns the computed default item height. Currently this method just gets the
Lines 4224-4229 Link Here
4224
        {
4383
        {
4225
            y += headerHeight;
4384
            y += headerHeight;
4226
        }
4385
        }
4386
        
4387
        if(columnFootersVisible) {
4388
        	y += footerHeight;
4389
        }
4227
4390
4228
        y += getGridHeight();
4391
        y += getGridHeight();
4229
4392
Lines 4612-4617 Link Here
4612
        return true;
4775
        return true;
4613
    }
4776
    }
4614
4777
4778
    private boolean handleColumnFooterPush(int x, int y)
4779
    {
4780
    	if(!columnFootersVisible) {
4781
    		return false;
4782
    	}
4783
    	
4784
    	GridColumn overThis = overColumnHeader(x, y);
4785
4786
        if (overThis == null)
4787
        {
4788
            return false;
4789
        }
4790
//        
4791
//        if (cellSelectionEnabled && overThis.getMoveable() == false)
4792
//        {
4793
//            return false;
4794
//        }      
4795
//
4796
//        columnBeingPushed = overThis;
4797
//
4798
//        // draw pushed
4799
//        columnBeingPushed.getHeaderRenderer().setMouseDown(true);
4800
//        columnBeingPushed.getHeaderRenderer().setHover(true);
4801
//        pushingAndHovering = true;
4802
//        redraw();
4803
//
4804
//        startHeaderPushX = x;
4805
//        pushingColumn = true;
4806
//        
4807
//        setCapture(true);
4808
4809
        return true;
4810
    }
4811
    
4615
    /**
4812
    /**
4616
     * Sets the new width of the column being resized and fires the appropriate
4813
     * Sets the new width of the column being resized and fires the appropriate
4617
     * listeners.
4814
     * listeners.
Lines 5238-5243 Link Here
5238
                    getClientArea().height);
5435
                    getClientArea().height);
5239
            insertMarkRenderer.paint(e.gc, new Rectangle(insertMarkPosX1, insertMarkPosY, insertMarkPosX2 - insertMarkPosX1, 0));
5436
            insertMarkRenderer.paint(e.gc, new Rectangle(insertMarkPosX1, insertMarkPosY, insertMarkPosX2 - insertMarkPosX1, 0));
5240
        }
5437
        }
5438
        
5439
        if (columnFootersVisible)
5440
        {
5441
            paintFooter(e.gc);
5442
        }
5241
    }
5443
    }
5242
5444
5243
    /**
5445
    /**
Lines 5475-5480 Link Here
5475
5677
5476
    }
5678
    }
5477
5679
5680
    private void paintFooter(GC gc) {
5681
    	int x = 0;
5682
        int y = 0;
5683
5684
        x -= getHScrollSelectionInPixels();
5685
        
5686
        if (rowHeaderVisible)
5687
        {
5688
            // paint left corner
5689
            // topLeftRenderer.setBounds(0, y, rowHeaderWidth, headerHeight);
5690
            // topLeftRenderer.paint(gc, null);
5691
            x += rowHeaderWidth;
5692
        }
5693
        
5694
        for (Iterator columnIterator = displayOrderedColumns.iterator(); columnIterator.hasNext(); ) {
5695
        	if (x > getClientArea().width)
5696
        		break;
5697
        	
5698
        	GridColumn column = (GridColumn) columnIterator.next();
5699
        	int height = 0;
5700
        	
5701
        	if (!column.isVisible())
5702
        	{
5703
        		continue;
5704
        	}
5705
5706
        	height = footerHeight;
5707
        	y = getClientArea().height - height;
5708
        	
5709
        	column.getFooterRenderer().setBounds(x, y, column.getWidth(), height);
5710
        	if (x + column.getWidth() >= 0)
5711
        	{
5712
        		column.getFooterRenderer().paint(gc, column);	
5713
        	}
5714
        	
5715
        	x += column.getWidth();
5716
        }
5717
        
5718
      if (x < getClientArea().width)
5719
      {
5720
    	  emptyColumnFooterRenderer.setBounds(x, getClientArea().height - footerHeight, getClientArea().width - x, footerHeight);
5721
    	  emptyColumnFooterRenderer.paint(gc, null);
5722
      }
5723
5724
    if (rowHeaderVisible)
5725
    {
5726
        // paint left corner
5727
    	bottomLeftRenderer.setBounds(0, getClientArea().height-footerHeight, rowHeaderWidth, footerHeight);
5728
    	bottomLeftRenderer.paint(gc, this);
5729
        x += rowHeaderWidth;
5730
    }
5731
      
5732
//
5733
//        GridColumnGroup previousPaintedGroup = null;
5734
//
5735
//        for (Iterator columnIterator = displayOrderedColumns.iterator(); columnIterator.hasNext(); )
5736
//        {
5737
//        	if (x > getClientArea().width)
5738
//        		break;
5739
//        	
5740
//            GridColumn column = (GridColumn) columnIterator.next();
5741
//            int height = 0;
5742
//            
5743
//            if (!column.isVisible())
5744
//            {
5745
//                continue;
5746
//            }
5747
//
5748
//            if (column.getColumnGroup() != null)
5749
//            {
5750
//
5751
//                if (column.getColumnGroup() != previousPaintedGroup)
5752
//                {
5753
//                    int width = column.getWidth();
5754
//
5755
//                    GridColumn nextCol = null;
5756
//                    if (displayOrderedColumns.indexOf(column) + 1 < displayOrderedColumns.size())
5757
//                    {
5758
//                        nextCol = (GridColumn)displayOrderedColumns
5759
//                            .get(displayOrderedColumns.indexOf(column) + 1);
5760
//                    }
5761
//
5762
//                    while (nextCol != null && nextCol.getColumnGroup() == column.getColumnGroup())
5763
//                    {
5764
//
5765
//                        if ((nextCol.getColumnGroup().getExpanded() && !nextCol.isDetail())
5766
//                            || (!nextCol.getColumnGroup().getExpanded() && !nextCol.isSummary()))
5767
//                        {
5768
//                        }
5769
//                        else
5770
//                        {
5771
//                            width += nextCol.getWidth();
5772
//                        }
5773
//
5774
//                        if (displayOrderedColumns.indexOf(nextCol) + 1 < displayOrderedColumns
5775
//                            .size())
5776
//                        {
5777
//                            nextCol = (GridColumn)displayOrderedColumns.get(displayOrderedColumns
5778
//                                .indexOf(nextCol) + 1);
5779
//                        }
5780
//                        else
5781
//                        {
5782
//                            nextCol = null;
5783
//                        }
5784
//                    }
5785
//                    
5786
//                    boolean selected = true;
5787
//                    
5788
//                    for (int i = 0; i < column.getColumnGroup().getColumns().length; i++)
5789
//                    {
5790
//                        GridColumn col = column.getColumnGroup().getColumns()[i];
5791
//                        if (col.isVisible() && (column.getMoveable() || !selectedColumns.contains(col)))
5792
//                        {
5793
//                            selected = false;
5794
//                            break;
5795
//                        }
5796
//                    }
5797
//
5798
//                    
5799
//                    column.getColumnGroup().getHeaderRenderer().setSelected(selected);
5800
//                    column.getColumnGroup().getHeaderRenderer()
5801
//                        .setHover(hoverColumnGroupHeader == column.getColumnGroup());
5802
//                    column.getColumnGroup().getHeaderRenderer().setHoverDetail(hoveringDetail);
5803
//
5804
//                    column.getColumnGroup().getHeaderRenderer().setBounds(x, 0, width,
5805
//                                                                          groupHeaderHeight);
5806
//
5807
//                    column.getColumnGroup().getHeaderRenderer().paint(gc, column.getColumnGroup());
5808
//
5809
//                    previousPaintedGroup = column.getColumnGroup();
5810
//                }
5811
//
5812
//                height = headerHeight - groupHeaderHeight;
5813
//                y = groupHeaderHeight;
5814
//            }
5815
//            else
5816
//            {
5817
//                height = headerHeight;
5818
//                y = 0;
5819
//            }
5820
//
5821
//            if (pushingColumn)
5822
//            {
5823
//                column.getHeaderRenderer().setHover(
5824
//                                                    columnBeingPushed == column
5825
//                                                        && pushingAndHovering);
5826
//            }
5827
//            else
5828
//            {
5829
//                column.getHeaderRenderer().setHover(hoveringColumnHeader == column);
5830
//            }
5831
//
5832
//            column.getHeaderRenderer().setHoverDetail(hoveringDetail);
5833
//
5834
//            column.getHeaderRenderer().setBounds(x, y, column.getWidth(), height);
5835
//            
5836
//            if (cellSelectionEnabled)
5837
//                column.getHeaderRenderer().setSelected(selectedColumns.contains(column));
5838
//            
5839
//            if (x + column.getWidth() >= 0)
5840
//            {
5841
//            	column.getHeaderRenderer().paint(gc, column);	
5842
//            }
5843
//
5844
//            x += column.getWidth();
5845
//        }
5846
//
5847
//        if (x < getClientArea().width)
5848
//        {
5849
//            emptyColumnHeaderRenderer.setBounds(x, 0, getClientArea().width - x, headerHeight);
5850
//            emptyColumnHeaderRenderer.paint(gc, null);
5851
//        }
5852
//        
5853
//        x = 0;
5854
//
5855
//        if (rowHeaderVisible)
5856
//        {
5857
//            // paint left corner
5858
//            topLeftRenderer.setBounds(0, 0, rowHeaderWidth, headerHeight);
5859
//            topLeftRenderer.paint(gc, this);
5860
//            x += rowHeaderWidth;
5861
//        }
5862
//
5863
//        if (draggingColumn)
5864
//        {
5865
//
5866
//            gc.setAlpha(COLUMN_DRAG_ALPHA);
5867
//
5868
//            columnBeingPushed.getHeaderRenderer().setSelected(false);
5869
//
5870
//            int height = 0;
5871
//
5872
//            if (columnBeingPushed.getColumnGroup() != null)
5873
//            {
5874
//                height = headerHeight - groupHeaderHeight;
5875
//                y = groupHeaderHeight;
5876
//            }
5877
//            else
5878
//            {
5879
//                height = headerHeight;
5880
//                y = 0;
5881
//            }
5882
//
5883
//            columnBeingPushed.getHeaderRenderer()
5884
//                .setBounds(
5885
//                           getColumnHeaderXPosition(columnBeingPushed)
5886
//                               + (currentHeaderDragX - startHeaderDragX), y,
5887
//                           columnBeingPushed.getWidth(), height);
5888
//            columnBeingPushed.getHeaderRenderer().paint(gc, columnBeingPushed);
5889
//            columnBeingPushed.getHeaderRenderer().setSelected(false);
5890
//
5891
//            gc.setAlpha(-1);
5892
//            gc.setAdvanced(false);
5893
//        }
5894
    }
5895
    
5478
    /**
5896
    /**
5479
     * Manages the state of the scrollbars when new items are added or the
5897
     * Manages the state of the scrollbars when new items are added or the
5480
     * bounds are changed.
5898
     * bounds are changed.
Lines 6248-6253 Link Here
6248
        {
6666
        {
6249
            return;
6667
            return;
6250
        }
6668
        }
6669
        
6670
        if(e.button == 1 && handleColumnFooterPush(e.x,e.y)) {
6671
        	return;
6672
        }
6251
6673
6252
        GridItem item = getItem(new Point(e.x, e.y));
6674
        GridItem item = getItem(new Point(e.x, e.y));
6253
        
6675
        
Lines 7424-7443 Link Here
7424
        {
7846
        {
7425
            if (item != null)
7847
            if (item != null)
7426
            {
7848
            {
7427
                col.getCellRenderer().setBounds(item.getBounds(columns.indexOf(col)));
7849
            	if( y < getClientArea().height - footerHeight  ) {
7850
                    col.getCellRenderer().setBounds(item.getBounds(columns.indexOf(col)));
7428
7851
7429
                if (col.getCellRenderer().notify(IInternalWidget.MouseMove, new Point(x, y), item))
7852
                    if (col.getCellRenderer().notify(IInternalWidget.MouseMove, new Point(x, y), item))
7430
                {
7853
                    {
7431
                    detail = col.getCellRenderer().getHoverDetail();
7854
                        detail = col.getCellRenderer().getHoverDetail();
7432
                }
7855
                    }
7433
7856
7434
                Rectangle textBounds = col.getCellRenderer().getTextBounds(item,false);
7857
                    Rectangle textBounds = col.getCellRenderer().getTextBounds(item,false);
7435
                
7858
                    
7436
                if (textBounds != null)
7859
                    if (textBounds != null)
7437
                {
7860
                    {
7438
                    Point p = new Point(x - col.getCellRenderer().getBounds().x, y - col.getCellRenderer().getBounds().y);
7861
                        Point p = new Point(x - col.getCellRenderer().getBounds().x, y - col.getCellRenderer().getBounds().y);
7439
                    overText = textBounds.contains(p);                  
7862
                        overText = textBounds.contains(p);                  
7440
                }               
7863
                    }            		
7864
            	}
7441
            }
7865
            }
7442
            else
7866
            else
7443
            {
7867
            {
Lines 7645-7650 Link Here
7645
        }
8069
        }
7646
8070
7647
        computeHeaderHeight(sizingGC);
8071
        computeHeaderHeight(sizingGC);
8072
        computeFooterHeight(sizingGC);
7648
8073
7649
        updatePrimaryCheckColumn();
8074
        updatePrimaryCheckColumn();
7650
        
8075
        
(-)src/org/eclipse/nebula/widgets/grid/internal/DefaultColumnFooterRenderer.java (+188 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    chris.gross@us.ibm.com - initial API and implementation
10
 *******************************************************************************/ 
11
package org.eclipse.nebula.widgets.grid.internal;
12
13
import org.eclipse.nebula.widgets.grid.GridColumn;
14
import org.eclipse.nebula.widgets.grid.GridFooterRenderer;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.graphics.GC;
17
import org.eclipse.swt.graphics.Point;
18
import org.eclipse.swt.graphics.Rectangle;
19
20
/**
21
 * The column footer renderer.
22
 *
23
 * @author Tom Schindl - tom.schindl@bestsolution.at
24
 * @since 2.0.0
25
 */
26
public class DefaultColumnFooterRenderer extends GridFooterRenderer
27
{
28
29
    int leftMargin = 6;
30
31
    int rightMargin = 6;
32
33
    int topMargin = 3;
34
35
    int bottomMargin = 3;
36
37
    int arrowMargin = 6;
38
39
    int imageSpacing = 3;
40
41
    /** 
42
     * {@inheritDoc}
43
     */
44
    public Point computeSize(GC gc, int wHint, int hHint, Object value)
45
    {
46
        GridColumn column = (GridColumn)value;
47
48
        int x = 0;
49
50
        x += leftMargin;
51
52
        x += gc.stringExtent(column.getText()).x + rightMargin;
53
54
        int y = 0;
55
56
        y += topMargin;
57
58
        y += gc.getFontMetrics().getHeight();
59
60
        y += bottomMargin;
61
62
        if (column.getFooterImage() != null)
63
        {
64
            x += column.getFooterImage().getBounds().width + imageSpacing;
65
66
            y = Math.max(y, topMargin + column.getFooterImage().getBounds().height + bottomMargin);
67
        }
68
69
        return new Point(x, y);
70
    }
71
72
    /** 
73
     * {@inheritDoc}
74
     */
75
    public void paint(GC gc, Object value)
76
    {
77
        GridColumn column = (GridColumn)value;
78
79
        gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
80
        gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
81
        
82
        gc.fillRectangle(getBounds().x, getBounds().y, getBounds().width,
83
                         getBounds().height);
84
        
85
        gc.drawLine(getBounds().x, getBounds().y, getBounds().x
86
                + getBounds().width, getBounds().y);
87
88
        int x = leftMargin;
89
90
        if (column.getFooterImage() != null)
91
        {
92
                gc.drawImage(column.getFooterImage(), getBounds().x + x,
93
                        getBounds().y + getBounds().height - bottomMargin - column.getFooterImage().getBounds().height);        		
94
            x += column.getFooterImage().getBounds().width + imageSpacing;
95
        }
96
97
        int width = getBounds().width - x;
98
99
        if (column.getSort() == SWT.NONE)
100
        {
101
            width -= rightMargin;
102
        }
103
        
104
105
        gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
106
107
        int y = getBounds().y + getBounds().height - bottomMargin - gc.getFontMetrics().getHeight();
108
109
        String text = TextUtils.getShortString(gc, column.getFooterText(), width);
110
        
111
        if (column.getAlignment() == SWT.RIGHT)
112
        {
113
            int len = gc.stringExtent(text).x;
114
            if (len < width)
115
            {
116
                x += width - len;
117
            }
118
        }
119
        else if (column.getAlignment() == SWT.CENTER)
120
        {
121
            int len = gc.stringExtent(text).x;
122
            if (len < width)
123
            {
124
                x += (width - len) / 2;
125
            }
126
        }
127
        
128
        
129
        gc.drawString(text, getBounds().x + x,
130
                      y,true);
131
132
    }
133
134
    /** 
135
     * {@inheritDoc}
136
     */
137
    public boolean notify(int event, Point point, Object value)
138
    {
139
        return false;
140
    }
141
142
    /** 
143
     * {@inheritDoc}
144
     */
145
    public Rectangle getTextBounds(Object value, boolean preferred)
146
    {
147
        GridColumn column = (GridColumn)value;
148
        
149
        int x = leftMargin;
150
151
        if (column.getImage() != null)
152
        {
153
            x += column.getImage().getBounds().width + imageSpacing;
154
        }
155
156
157
158
        GC gc = new GC(column.getParent());
159
        gc.setFont(column.getParent().getFont());
160
        int y = getBounds().height - bottomMargin - gc.getFontMetrics().getHeight();
161
        
162
        Rectangle bounds = new Rectangle(x,y,0,0);
163
        
164
        Point p = gc.stringExtent(column.getText());
165
        
166
        bounds.height = p.y;
167
        
168
        if (preferred)
169
        {
170
            bounds.width = p.x;
171
        }
172
        else
173
        {
174
            int width = getBounds().width - x;
175
            if (column.getSort() == SWT.NONE)
176
            {
177
                width -= rightMargin;
178
            }
179
            
180
            bounds.width = width;
181
        }
182
        
183
        
184
        gc.dispose();
185
        
186
        return bounds;        
187
    }    
188
}
(-)src/org/eclipse/nebula/widgets/grid/internal/DefaultBottomLeftRenderer.java (+52 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    chris.gross@us.ibm.com - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.nebula.widgets.grid.internal;
12
13
import org.eclipse.nebula.widgets.grid.AbstractRenderer;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.graphics.GC;
16
import org.eclipse.swt.graphics.Point;
17
18
/**
19
 * The renderer for the empty top left area when both column and row headers are
20
 * visible.
21
 * 
22
 * @author chris.gross@us.ibm.com
23
 * @since 2.0.0
24
 */
25
public class DefaultBottomLeftRenderer extends AbstractRenderer {
26
27
	/**
28
	 * {@inheritDoc}
29
	 */
30
	public Point computeSize(GC gc, int wHint, int hHint, Object value) {
31
		return new Point(wHint, hHint);
32
	}
33
34
	/**
35
	 * {@inheritDoc}
36
	 */
37
	public void paint(GC gc, Object value) {
38
		gc.setBackground(getDisplay().getSystemColor(
39
				SWT.COLOR_WIDGET_BACKGROUND));
40
41
		gc.fillRectangle(getBounds().x, getBounds().y, getBounds().width,
42
				getBounds().height + 1);
43
44
		gc.setForeground(getDisplay().getSystemColor(
45
				SWT.COLOR_WIDGET_DARK_SHADOW));
46
47
		gc.drawLine(getBounds().x, getBounds().y, getBounds().x
48
				+ getBounds().width, getBounds().y);
49
50
	}
51
52
}
(-)src/org/eclipse/nebula/widgets/grid/internal/DefaultEmptyColumnFooterRenderer.java (+48 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    chris.gross@us.ibm.com - initial API and implementation
10
 *******************************************************************************/ 
11
package org.eclipse.nebula.widgets.grid.internal;
12
13
import org.eclipse.nebula.widgets.grid.AbstractRenderer;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.graphics.GC;
16
import org.eclipse.swt.graphics.Point;
17
18
/**
19
 * A renderer for the last empty column header.
20
 *
21
 * @author chris.gross@us.ibm.com
22
 * @since 2.0.0
23
 */
24
public class DefaultEmptyColumnFooterRenderer extends AbstractRenderer
25
{
26
27
    /** 
28
     * {@inheritDoc}
29
     */
30
    public Point computeSize(GC gc, int wHint, int hHint, Object value)
31
    {
32
        return new Point(wHint, hHint);
33
    }
34
35
    /** 
36
     * {@inheritDoc}
37
     */
38
    public void paint(GC gc, Object value)
39
    {
40
        gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
41
42
        gc.fillRectangle(getBounds().x, getBounds().y, getBounds().width + 1,
43
                         getBounds().height + 1);
44
        gc.drawLine(getBounds().x, getBounds().y, getBounds().x
45
                + getBounds().width, getBounds().y);
46
    }
47
48
}
(-)src/org/eclipse/nebula/widgets/grid/GridFooterRenderer.java (+32 lines)
Added Link Here
1
package org.eclipse.nebula.widgets.grid;
2
3
import org.eclipse.swt.graphics.Rectangle;
4
5
/**
6
 * <p>
7
 * NOTE:  THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT.  THIS IS A PRE-RELEASE ALPHA 
8
 * VERSION.  USERS SHOULD EXPECT API CHANGES IN FUTURE VERSIONS.
9
 * </p> 
10
 * The super class for all grid header renderers.  Contains the properties specific
11
 * to a grid header.
12
 *
13
 * @author chris.gross@us.ibm.com
14
 */
15
public abstract class GridFooterRenderer extends AbstractInternalWidget
16
{
17
    /**
18
     * Returns the bounds of the text in the cell.  This is used when displaying in-place tooltips.
19
     * If <code>null</code> is returned here, in-place tooltips will not be displayed.  If the 
20
     * <code>preferred</code> argument is <code>true</code> then the returned bounds should be large
21
     * enough to show the entire text.  If <code>preferred</code> is <code>false</code> then the 
22
     * returned bounds should be be relative to the current bounds.
23
     * 
24
     * @param value the object being rendered.
25
     * @param preferred true if the preferred width of the text should be returned.
26
     * @return bounds of the text.
27
     */
28
    public Rectangle getTextBounds(Object value, boolean preferred)
29
    {
30
        return null;
31
    }
32
}

Return to bug 237916