Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 105634 Details for
Bug 237916
Add possibility to add a ColumnFooterRenderer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Remove commented code parts
patch.txt (text/plain), 31.96 KB, created by
Thomas Schindl
on 2008-06-23 09:58:12 EDT
(
hide
)
Description:
Remove commented code parts
Filename:
MIME Type:
Creator:
Thomas Schindl
Created:
2008-06-23 09:58:12 EDT
Size:
31.96 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.nebula.widgets.grid >Index: src/org/eclipse/nebula/widgets/grid/GridColumn.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.swt.nebula/org.eclipse.nebula.widgets.grid/src/org/eclipse/nebula/widgets/grid/GridColumn.java,v >retrieving revision 1.5 >diff -u -r1.5 GridColumn.java >--- src/org/eclipse/nebula/widgets/grid/GridColumn.java 7 May 2007 15:03:33 -0000 1.5 >+++ src/org/eclipse/nebula/widgets/grid/GridColumn.java 23 Jun 2008 13:56:46 -0000 >@@ -11,11 +11,14 @@ > package org.eclipse.nebula.widgets.grid; > > import org.eclipse.nebula.widgets.grid.internal.DefaultCellRenderer; >+import org.eclipse.nebula.widgets.grid.internal.DefaultColumnFooterRenderer; > import org.eclipse.nebula.widgets.grid.internal.DefaultColumnHeaderRenderer; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.SWTException; > import org.eclipse.swt.events.ControlListener; > import org.eclipse.swt.events.SelectionListener; > import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Event; >@@ -55,6 +58,8 @@ > * Header renderer. > */ > private GridHeaderRenderer headerRenderer = new DefaultColumnHeaderRenderer(); >+ >+ private GridFooterRenderer footerRenderer = new DefaultColumnFooterRenderer(); > > /** > * Cell renderer. >@@ -118,6 +123,10 @@ > private GridColumnGroup group; > > private boolean checkable = true; >+ >+ private Image footerImage; >+ >+ private String footerText = ""; > > /** > * Constructs a new instance of this class given its parent (which must be a >@@ -215,6 +224,7 @@ > } > > initHeaderRenderer(); >+ initFooterRenderer(); > initCellRenderer(); > } > >@@ -239,6 +249,14 @@ > { > headerRenderer.setDisplay(getDisplay()); > } >+ >+ /** >+ * Initialize header renderer. >+ */ >+ private void initFooterRenderer() >+ { >+ footerRenderer.setDisplay(getDisplay()); >+ } > > /** > * Initialize cell renderer. >@@ -273,6 +291,11 @@ > return headerRenderer; > } > >+ >+ GridFooterRenderer getFooterRenderer() { >+ return footerRenderer; >+ } >+ > /** > * Returns the cell renderer. > * >@@ -619,6 +642,24 @@ > this.headerRenderer = headerRenderer; > initHeaderRenderer(); > } >+ >+ /** >+ * Sets the header renderer. >+ * >+ * @param footerRenderer The footerRenderer to set. >+ * @throws org.eclipse.swt.SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that >+ * created the receiver</li> >+ * </ul> >+ */ >+ public void setFooterRenderer(GridFooterRenderer footerRenderer) >+ { >+ checkWidget(); >+ this.footerRenderer = footerRenderer; >+ initFooterRenderer(); >+ } > > /** > * Adds a listener to the list of listeners notified when the column is >@@ -1086,4 +1127,75 @@ > cellRenderer.setWordWrap(wordWrap); > parent.redraw(); > } >+ >+ /** >+ * Sets the receiver's footer image to the argument, which may be >+ * null indicating that no image should be displayed. >+ * >+ * @param image the image to display on the receiver (may be null) >+ * >+ * @exception IllegalArgumentException <ul> >+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> >+ * </ul> >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setFooterImage (Image image) { >+ checkWidget (); >+ if (image != null && image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); >+ this.footerImage = image; >+ } >+ >+ /** >+ * Sets the receiver's footer text. >+ * >+ * @param string the new text >+ * >+ * @exception IllegalArgumentException <ul> >+ * <li>ERROR_NULL_ARGUMENT - if the text is null</li> >+ * </ul> >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setFooterText (String string) { >+ checkWidget (); >+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); >+ this.footerText = string; >+ } >+ >+ /** >+ * Returns the receiver's footer image if it has one, or null >+ * if it does not. >+ * >+ * @return the receiver's image >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public Image getFooterImage () { >+ checkWidget (); >+ return footerImage; >+ } >+ >+ /** >+ * Returns the receiver's footer text, which will be an empty >+ * string if it has never been set. >+ * >+ * @return the receiver's text >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public String getFooterText () { >+ checkWidget(); >+ return footerText; >+ } > } >Index: src/org/eclipse/nebula/widgets/grid/Grid.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.swt.nebula/org.eclipse.nebula.widgets.grid/src/org/eclipse/nebula/widgets/grid/Grid.java,v >retrieving revision 1.63 >diff -u -r1.63 Grid.java >--- src/org/eclipse/nebula/widgets/grid/Grid.java 27 Feb 2008 16:42:07 -0000 1.63 >+++ src/org/eclipse/nebula/widgets/grid/Grid.java 23 Jun 2008 13:56:46 -0000 >@@ -16,9 +16,11 @@ > import java.util.List; > import java.util.Vector; > >+import org.eclipse.nebula.widgets.grid.internal.DefaultBottomLeftRenderer; > import org.eclipse.nebula.widgets.grid.internal.DefaultColumnGroupHeaderRenderer; > import org.eclipse.nebula.widgets.grid.internal.DefaultDropPointRenderer; > import org.eclipse.nebula.widgets.grid.internal.DefaultEmptyCellRenderer; >+import org.eclipse.nebula.widgets.grid.internal.DefaultEmptyColumnFooterRenderer; > import org.eclipse.nebula.widgets.grid.internal.DefaultEmptyColumnHeaderRenderer; > import org.eclipse.nebula.widgets.grid.internal.DefaultEmptyRowHeaderRenderer; > import org.eclipse.nebula.widgets.grid.internal.DefaultFocusRenderer; >@@ -249,6 +251,11 @@ > * shown. > */ > private IRenderer topLeftRenderer = new DefaultTopLeftRenderer(); >+ >+ /** >+ * Renderer to paint the bottom left area when row headers and column footers are shown >+ */ >+ private IRenderer bottomLeftRenderer = new DefaultBottomLeftRenderer(); > > /** > * Renderer used to paint row headers. >@@ -262,6 +269,12 @@ > private IRenderer emptyColumnHeaderRenderer = new DefaultEmptyColumnHeaderRenderer(); > > /** >+ * Renderer used to paint empty column footers, used when the columns don't >+ * fill the horz space. >+ */ >+ private IRenderer emptyColumnFooterRenderer = new DefaultEmptyColumnFooterRenderer(); >+ >+ /** > * Renderer used to paint empty cells to fill horz and vert space. > */ > private GridCellRenderer emptyCellRenderer = new DefaultEmptyCellRenderer(); >@@ -294,6 +307,11 @@ > private boolean columnHeadersVisible = false; > > /** >+ * Are column footers visible? >+ */ >+ private boolean columnFootersVisible = false; >+ >+ /** > * Type of selection behavior. Valid values are SWT.SINGLE and SWT.MULTI. > */ > private int selectionType = SWT.SINGLE; >@@ -333,6 +351,11 @@ > * Height of each column header. > */ > private int headerHeight = 0; >+ >+ /** >+ * Height of each column footer >+ */ >+ private int footerHeight = 0; > > /** > * True if mouse is hover on a column boundary and can resize the column. >@@ -685,8 +708,10 @@ > sizingGC = new GC(this); > > topLeftRenderer.setDisplay(getDisplay()); >+ bottomLeftRenderer.setDisplay(getDisplay()); > rowHeaderRenderer.setDisplay(getDisplay()); > emptyColumnHeaderRenderer.setDisplay(getDisplay()); >+ emptyColumnFooterRenderer.setDisplay(getDisplay()); > emptyCellRenderer.setDisplay(getDisplay()); > dropPointRenderer.setDisplay(getDisplay()); > focusRenderer.setDisplay(getDisplay()); >@@ -1487,6 +1512,22 @@ > } > > /** >+ * Returns the empty column footer renderer. >+ * >+ * @return Returns the emptyColumnFooterRenderer. >+ * @throws org.eclipse.swt.SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that >+ * created the receiver</li> >+ * </ul> >+ */ >+ public IRenderer getEmptyColumnFooterRenderer() { >+ checkWidget(); >+ return emptyColumnFooterRenderer; >+ } >+ >+ /** > * Returns the empty row header renderer. > * > * @return Returns the emptyRowHeaderRenderer. >@@ -1575,6 +1616,22 @@ > } > > /** >+ * Returns the height of the column footers. >+ * >+ * @return height of the column footer row >+ * @throws org.eclipse.swt.SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that >+ * created the receiver</li> >+ * </ul> >+ */ >+ public int getFooterHeight() { >+ checkWidget(); >+ return footerHeight; >+ } >+ >+ /** > * Returns the height of the column group headers. > * > * @return height of column group headers >@@ -1610,6 +1667,21 @@ > } > > /** >+ * Returns {@code true} if the receiver's footer is visible, and {@code false} otherwise >+ * @return the receiver's footer's visibility state >+ * @throws org.eclipse.swt.SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that >+ * created the receiver</li> >+ * </ul> >+ */ >+ public boolean getFooterVisible() { >+ checkWidget(); >+ return columnFootersVisible; >+ } >+ >+ /** > * Returns the item at the given, zero-relative index in the receiver. > * Throws an exception if the index is out of range. > * >@@ -2660,7 +2732,7 @@ > * @return height of visible grid in pixels > */ > int getVisibleGridHeight() { >- return getClientArea().height - (columnHeadersVisible ? headerHeight : 0); >+ return getClientArea().height - (columnHeadersVisible ? headerHeight : 0) - (columnFootersVisible ? footerHeight : 0); > } > > /** >@@ -2679,6 +2751,23 @@ > checkWidget(); > return topLeftRenderer; > } >+ >+ /** >+ * Gets the bottom left renderer. >+ * >+ * @return Returns the bottomLeftRenderer. >+ * @throws org.eclipse.swt.SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that >+ * created the receiver</li> >+ * </ul> >+ */ >+ public IRenderer getBottomLeftRenderer() >+ { >+ checkWidget(); >+ return bottomLeftRenderer; >+ } > > /** > * Searches the receiver's list starting at the first column (index 0) until >@@ -3269,6 +3358,24 @@ > emptyColumnHeaderRenderer.setDisplay(getDisplay()); > this.emptyColumnHeaderRenderer = emptyColumnHeaderRenderer; > } >+ >+ /** >+ * Sets the empty column footer renderer. >+ * >+ * @param emptyColumnFooterRenderer The emptyColumnFooterRenderer to set. >+ * @throws org.eclipse.swt.SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that >+ * created the receiver</li> >+ * </ul> >+ */ >+ public void setEmptyColumnFooterRenderer(IRenderer emptyColumnFooterRenderer) >+ { >+ checkWidget(); >+ emptyColumnFooterRenderer.setDisplay(getDisplay()); >+ this.emptyColumnFooterRenderer = emptyColumnFooterRenderer; >+ } > > /** > * Sets the empty row header renderer. >@@ -3395,6 +3502,25 @@ > this.columnHeadersVisible = show; > redraw(); > } >+ >+ /** >+ * Marks the receiver's footer as visible if the argument is {@code true}, >+ * and marks it invisible otherwise. >+ * >+ * @param show the new visibility state >+ * @throws org.eclipse.swt.SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that >+ * created the receiver</li> >+ * </ul> >+ */ >+ public void setFooterVisible(boolean show) >+ { >+ checkWidget(); >+ this.columnFootersVisible = show; >+ redraw(); >+ } > > /** > * Sets the line color. >@@ -3798,6 +3924,24 @@ > topLeftRenderer.setDisplay(getDisplay()); > this.topLeftRenderer = topLeftRenderer; > } >+ >+ /** >+ * Sets the bottom left renderer. >+ * >+ * @param bottomLeftRenderer The topLeftRenderer to set. >+ * @throws org.eclipse.swt.SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that >+ * created the receiver</li> >+ * </ul> >+ */ >+ public void setBottomLeftRenderer(IRenderer bottomLeftRenderer) >+ { >+ checkWidget(); >+ bottomLeftRenderer.setDisplay(getDisplay()); >+ this.bottomLeftRenderer = bottomLeftRenderer; >+ } > > /** > * Shows the column. If the column is already showing in the receiver, this >@@ -4117,6 +4261,21 @@ > headerHeight = colHeaderHeight + groupHeight; > groupHeaderHeight = groupHeight; > } >+ >+ private void computeFooterHeight(GC gc) >+ { >+ >+ int colFooterHeight = 0; >+ for (Iterator columnsIterator = columns.iterator(); columnsIterator.hasNext(); ) >+ { >+ GridColumn column = (GridColumn) columnsIterator.next(); >+ colFooterHeight = Math >+ .max(column.getFooterRenderer().computeSize(gc, column.getWidth(), SWT.DEFAULT, >+ column).y, colFooterHeight); >+ } >+ >+ footerHeight = colFooterHeight; >+ } > > /** > * Returns the computed default item height. Currently this method just gets the >@@ -4224,6 +4383,10 @@ > { > y += headerHeight; > } >+ >+ if(columnFootersVisible) { >+ y += footerHeight; >+ } > > y += getGridHeight(); > >@@ -4612,6 +4775,22 @@ > return true; > } > >+ private boolean handleColumnFooterPush(int x, int y) >+ { >+ if(!columnFootersVisible) { >+ return false; >+ } >+ >+ GridColumn overThis = overColumnFooter(x, y); >+ >+ if (overThis == null) >+ { >+ return false; >+ } >+ >+ return true; >+ } >+ > /** > * Sets the new width of the column being resized and fires the appropriate > * listeners. >@@ -5238,6 +5417,11 @@ > getClientArea().height); > insertMarkRenderer.paint(e.gc, new Rectangle(insertMarkPosX1, insertMarkPosY, insertMarkPosX2 - insertMarkPosX1, 0)); > } >+ >+ if (columnFootersVisible) >+ { >+ paintFooter(e.gc); >+ } > } > > /** >@@ -5266,6 +5450,26 @@ > > return col; > } >+ >+ /** >+ * Returns a column reference if the x,y coordinates are over a column >+ * header (header only). >+ * >+ * @param x mouse x >+ * @param y mouse y >+ * @return column reference which mouse is over, or null. >+ */ >+ private GridColumn overColumnFooter(int x, int y) >+ { >+ GridColumn col = null; >+ >+ if (y >= getClientArea().height - footerHeight ) >+ { >+ col = getColumn(new Point(x, y)); >+ } >+ >+ return col; >+ } > > /** > * Returns a column group reference if the x,y coordinates are over a column >@@ -5475,6 +5679,59 @@ > > } > >+ private void paintFooter(GC gc) { >+ int x = 0; >+ int y = 0; >+ >+ x -= getHScrollSelectionInPixels(); >+ >+ if (rowHeaderVisible) >+ { >+ // paint left corner >+ // topLeftRenderer.setBounds(0, y, rowHeaderWidth, headerHeight); >+ // topLeftRenderer.paint(gc, null); >+ x += rowHeaderWidth; >+ } >+ >+ for (Iterator columnIterator = displayOrderedColumns.iterator(); columnIterator.hasNext(); ) { >+ if (x > getClientArea().width) >+ break; >+ >+ GridColumn column = (GridColumn) columnIterator.next(); >+ int height = 0; >+ >+ if (!column.isVisible()) >+ { >+ continue; >+ } >+ >+ height = footerHeight; >+ y = getClientArea().height - height; >+ >+ column.getFooterRenderer().setBounds(x, y, column.getWidth(), height); >+ if (x + column.getWidth() >= 0) >+ { >+ column.getFooterRenderer().paint(gc, column); >+ } >+ >+ x += column.getWidth(); >+ } >+ >+ if (x < getClientArea().width) >+ { >+ emptyColumnFooterRenderer.setBounds(x, getClientArea().height - footerHeight, getClientArea().width - x, footerHeight); >+ emptyColumnFooterRenderer.paint(gc, null); >+ } >+ >+ if (rowHeaderVisible) >+ { >+ // paint left corner >+ bottomLeftRenderer.setBounds(0, getClientArea().height-footerHeight, rowHeaderWidth, footerHeight); >+ bottomLeftRenderer.paint(gc, this); >+ x += rowHeaderWidth; >+ } >+ } >+ > /** > * Manages the state of the scrollbars when new items are added or the > * bounds are changed. >@@ -6248,6 +6505,10 @@ > { > return; > } >+ >+ if(e.button == 1 && handleColumnFooterPush(e.x,e.y)) { >+ return; >+ } > > GridItem item = getItem(new Point(e.x, e.y)); > >@@ -7424,20 +7685,22 @@ > { > if (item != null) > { >- col.getCellRenderer().setBounds(item.getBounds(columns.indexOf(col))); >+ if( y < getClientArea().height - footerHeight ) { >+ col.getCellRenderer().setBounds(item.getBounds(columns.indexOf(col))); > >- if (col.getCellRenderer().notify(IInternalWidget.MouseMove, new Point(x, y), item)) >- { >- detail = col.getCellRenderer().getHoverDetail(); >- } >+ if (col.getCellRenderer().notify(IInternalWidget.MouseMove, new Point(x, y), item)) >+ { >+ detail = col.getCellRenderer().getHoverDetail(); >+ } > >- Rectangle textBounds = col.getCellRenderer().getTextBounds(item,false); >- >- if (textBounds != null) >- { >- Point p = new Point(x - col.getCellRenderer().getBounds().x, y - col.getCellRenderer().getBounds().y); >- overText = textBounds.contains(p); >- } >+ Rectangle textBounds = col.getCellRenderer().getTextBounds(item,false); >+ >+ if (textBounds != null) >+ { >+ Point p = new Point(x - col.getCellRenderer().getBounds().x, y - col.getCellRenderer().getBounds().y); >+ overText = textBounds.contains(p); >+ } >+ } > } > else > { >@@ -7645,6 +7908,7 @@ > } > > computeHeaderHeight(sizingGC); >+ computeFooterHeight(sizingGC); > > updatePrimaryCheckColumn(); > >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.swt.nebula/org.eclipse.nebula.widgets.grid/META-INF/MANIFEST.MF,v >retrieving revision 1.3 >diff -u -r1.3 MANIFEST.MF >--- META-INF/MANIFEST.MF 29 Mar 2007 14:57:47 -0000 1.3 >+++ META-INF/MANIFEST.MF 23 Jun 2008 13:56:45 -0000 >@@ -6,4 +6,4 @@ > Bundle-RequiredExecutionEnvironment: J2SE-1.4 > Require-Bundle: org.eclipse.swt > Export-Package: org.eclipse.nebula.widgets.grid, >- org.eclipse.nebula.widgets.grid.internal >+ org.eclipse.nebula.widgets.grid.internal;x-internal:=true >Index: src/org/eclipse/nebula/widgets/grid/internal/DefaultColumnFooterRenderer.java >=================================================================== >RCS file: src/org/eclipse/nebula/widgets/grid/internal/DefaultColumnFooterRenderer.java >diff -N src/org/eclipse/nebula/widgets/grid/internal/DefaultColumnFooterRenderer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/nebula/widgets/grid/internal/DefaultColumnFooterRenderer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,188 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * chris.gross@us.ibm.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.nebula.widgets.grid.internal; >+ >+import org.eclipse.nebula.widgets.grid.GridColumn; >+import org.eclipse.nebula.widgets.grid.GridFooterRenderer; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+ >+/** >+ * The column footer renderer. >+ * >+ * @author Tom Schindl - tom.schindl@bestsolution.at >+ * @since 2.0.0 >+ */ >+public class DefaultColumnFooterRenderer extends GridFooterRenderer >+{ >+ >+ int leftMargin = 6; >+ >+ int rightMargin = 6; >+ >+ int topMargin = 3; >+ >+ int bottomMargin = 3; >+ >+ int arrowMargin = 6; >+ >+ int imageSpacing = 3; >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public Point computeSize(GC gc, int wHint, int hHint, Object value) >+ { >+ GridColumn column = (GridColumn)value; >+ >+ int x = 0; >+ >+ x += leftMargin; >+ >+ x += gc.stringExtent(column.getText()).x + rightMargin; >+ >+ int y = 0; >+ >+ y += topMargin; >+ >+ y += gc.getFontMetrics().getHeight(); >+ >+ y += bottomMargin; >+ >+ if (column.getFooterImage() != null) >+ { >+ x += column.getFooterImage().getBounds().width + imageSpacing; >+ >+ y = Math.max(y, topMargin + column.getFooterImage().getBounds().height + bottomMargin); >+ } >+ >+ return new Point(x, y); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void paint(GC gc, Object value) >+ { >+ GridColumn column = (GridColumn)value; >+ >+ gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); >+ gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); >+ >+ gc.fillRectangle(getBounds().x, getBounds().y, getBounds().width, >+ getBounds().height); >+ >+ gc.drawLine(getBounds().x, getBounds().y, getBounds().x >+ + getBounds().width, getBounds().y); >+ >+ int x = leftMargin; >+ >+ if (column.getFooterImage() != null) >+ { >+ gc.drawImage(column.getFooterImage(), getBounds().x + x, >+ getBounds().y + getBounds().height - bottomMargin - column.getFooterImage().getBounds().height); >+ x += column.getFooterImage().getBounds().width + imageSpacing; >+ } >+ >+ int width = getBounds().width - x; >+ >+ if (column.getSort() == SWT.NONE) >+ { >+ width -= rightMargin; >+ } >+ >+ >+ gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); >+ >+ int y = getBounds().y + getBounds().height - bottomMargin - gc.getFontMetrics().getHeight(); >+ >+ String text = TextUtils.getShortString(gc, column.getFooterText(), width); >+ >+ if (column.getAlignment() == SWT.RIGHT) >+ { >+ int len = gc.stringExtent(text).x; >+ if (len < width) >+ { >+ x += width - len; >+ } >+ } >+ else if (column.getAlignment() == SWT.CENTER) >+ { >+ int len = gc.stringExtent(text).x; >+ if (len < width) >+ { >+ x += (width - len) / 2; >+ } >+ } >+ >+ >+ gc.drawString(text, getBounds().x + x, >+ y,true); >+ >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean notify(int event, Point point, Object value) >+ { >+ return false; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public Rectangle getTextBounds(Object value, boolean preferred) >+ { >+ GridColumn column = (GridColumn)value; >+ >+ int x = leftMargin; >+ >+ if (column.getImage() != null) >+ { >+ x += column.getImage().getBounds().width + imageSpacing; >+ } >+ >+ >+ >+ GC gc = new GC(column.getParent()); >+ gc.setFont(column.getParent().getFont()); >+ int y = getBounds().height - bottomMargin - gc.getFontMetrics().getHeight(); >+ >+ Rectangle bounds = new Rectangle(x,y,0,0); >+ >+ Point p = gc.stringExtent(column.getText()); >+ >+ bounds.height = p.y; >+ >+ if (preferred) >+ { >+ bounds.width = p.x; >+ } >+ else >+ { >+ int width = getBounds().width - x; >+ if (column.getSort() == SWT.NONE) >+ { >+ width -= rightMargin; >+ } >+ >+ bounds.width = width; >+ } >+ >+ >+ gc.dispose(); >+ >+ return bounds; >+ } >+} >Index: src/org/eclipse/nebula/widgets/grid/internal/DefaultBottomLeftRenderer.java >=================================================================== >RCS file: src/org/eclipse/nebula/widgets/grid/internal/DefaultBottomLeftRenderer.java >diff -N src/org/eclipse/nebula/widgets/grid/internal/DefaultBottomLeftRenderer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/nebula/widgets/grid/internal/DefaultBottomLeftRenderer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,52 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * chris.gross@us.ibm.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.nebula.widgets.grid.internal; >+ >+import org.eclipse.nebula.widgets.grid.AbstractRenderer; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Point; >+ >+/** >+ * The renderer for the empty top left area when both column and row headers are >+ * visible. >+ * >+ * @author chris.gross@us.ibm.com >+ * @since 2.0.0 >+ */ >+public class DefaultBottomLeftRenderer extends AbstractRenderer { >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public Point computeSize(GC gc, int wHint, int hHint, Object value) { >+ return new Point(wHint, hHint); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void paint(GC gc, Object value) { >+ gc.setBackground(getDisplay().getSystemColor( >+ SWT.COLOR_WIDGET_BACKGROUND)); >+ >+ gc.fillRectangle(getBounds().x, getBounds().y, getBounds().width, >+ getBounds().height + 1); >+ >+ gc.setForeground(getDisplay().getSystemColor( >+ SWT.COLOR_WIDGET_DARK_SHADOW)); >+ >+ gc.drawLine(getBounds().x, getBounds().y, getBounds().x >+ + getBounds().width, getBounds().y); >+ >+ } >+ >+} >Index: src/org/eclipse/nebula/widgets/grid/internal/DefaultEmptyColumnFooterRenderer.java >=================================================================== >RCS file: src/org/eclipse/nebula/widgets/grid/internal/DefaultEmptyColumnFooterRenderer.java >diff -N src/org/eclipse/nebula/widgets/grid/internal/DefaultEmptyColumnFooterRenderer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/nebula/widgets/grid/internal/DefaultEmptyColumnFooterRenderer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,48 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * chris.gross@us.ibm.com - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.nebula.widgets.grid.internal; >+ >+import org.eclipse.nebula.widgets.grid.AbstractRenderer; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Point; >+ >+/** >+ * A renderer for the last empty column header. >+ * >+ * @author chris.gross@us.ibm.com >+ * @since 2.0.0 >+ */ >+public class DefaultEmptyColumnFooterRenderer extends AbstractRenderer >+{ >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public Point computeSize(GC gc, int wHint, int hHint, Object value) >+ { >+ return new Point(wHint, hHint); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void paint(GC gc, Object value) >+ { >+ gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); >+ >+ gc.fillRectangle(getBounds().x, getBounds().y, getBounds().width + 1, >+ getBounds().height + 1); >+ gc.drawLine(getBounds().x, getBounds().y, getBounds().x >+ + getBounds().width, getBounds().y); >+ } >+ >+} >Index: src/org/eclipse/nebula/widgets/grid/GridFooterRenderer.java >=================================================================== >RCS file: src/org/eclipse/nebula/widgets/grid/GridFooterRenderer.java >diff -N src/org/eclipse/nebula/widgets/grid/GridFooterRenderer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/nebula/widgets/grid/GridFooterRenderer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,32 @@ >+package org.eclipse.nebula.widgets.grid; >+ >+import org.eclipse.swt.graphics.Rectangle; >+ >+/** >+ * <p> >+ * NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT. THIS IS A PRE-RELEASE ALPHA >+ * VERSION. USERS SHOULD EXPECT API CHANGES IN FUTURE VERSIONS. >+ * </p> >+ * The super class for all grid header renderers. Contains the properties specific >+ * to a grid header. >+ * >+ * @author chris.gross@us.ibm.com >+ */ >+public abstract class GridFooterRenderer extends AbstractInternalWidget >+{ >+ /** >+ * Returns the bounds of the text in the cell. This is used when displaying in-place tooltips. >+ * If <code>null</code> is returned here, in-place tooltips will not be displayed. If the >+ * <code>preferred</code> argument is <code>true</code> then the returned bounds should be large >+ * enough to show the entire text. If <code>preferred</code> is <code>false</code> then the >+ * returned bounds should be be relative to the current bounds. >+ * >+ * @param value the object being rendered. >+ * @param preferred true if the preferred width of the text should be returned. >+ * @return bounds of the text. >+ */ >+ public Rectangle getTextBounds(Object value, boolean preferred) >+ { >+ return null; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
wayne.beaton
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 237916
:
105486
|
105633
| 105634