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 160183 Details for
Bug 303883
[Forms] Get use of GC again where it is possible
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]
Patch
Bug-303883.patch (text/plain), 53.46 KB, created by
Ivan Furnadjiev
on 2010-02-25 08:52:22 EST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Ivan Furnadjiev
Created:
2010-02-25 08:52:22 EST
Size:
53.46 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.ui.forms >Index: src/org/eclipse/ui/internal/forms/widgets/ControlSegment.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/ControlSegment.java,v >retrieving revision 1.2 >diff -u -r1.2 ControlSegment.java >--- src/org/eclipse/ui/internal/forms/widgets/ControlSegment.java 16 Mar 2009 10:12:31 -0000 1.2 >+++ src/org/eclipse/ui/internal/forms/widgets/ControlSegment.java 25 Feb 2010 13:25:33 -0000 >@@ -13,9 +13,7 @@ > import java.util.Hashtable; > > import org.eclipse.swt.SWT; >-//RAP [if] GC not supported >-//import org.eclipse.swt.graphics.GC; >-import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.widgets.Canvas; > import org.eclipse.swt.widgets.Composite; >@@ -66,12 +64,9 @@ > return size; > } > >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public void layout(GC gc, int width, Locator loc, Hashtable resourceTable, >- public void layout(Font font, int width, Locator loc, Hashtable resourceTable, >+ public void layout(GC gc, int width, Locator loc, Hashtable resourceTable, > boolean selected) { >-// super.layout(gc, width, loc, resourceTable, selected); >- super.layout(font, width, loc, resourceTable, selected); >+ super.layout(gc, width, loc, resourceTable, selected); > Control control = getControl(resourceTable); > if (control!=null) > control.setBounds(getBounds()); >Index: src/org/eclipse/ui/internal/forms/widgets/TextSegment.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/TextSegment.java,v >retrieving revision 1.3 >diff -u -r1.3 TextSegment.java >--- src/org/eclipse/ui/internal/forms/widgets/TextSegment.java 2 Apr 2009 07:51:45 -0000 1.3 >+++ src/org/eclipse/ui/internal/forms/widgets/TextSegment.java 25 Feb 2010 13:25:33 -0000 >@@ -15,14 +15,12 @@ > import java.util.Vector; > > import org.eclipse.rwt.Adaptable; >-import org.eclipse.rwt.graphics.Graphics; > import org.eclipse.swt.SWT; > // RAP [if] unnecessary > //import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Font; >-//RAP [if] GC/FontMetrics not supported >-//import org.eclipse.swt.graphics.FontMetrics; >-//import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.FontMetrics; >+import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.ui.forms.internal.widgets.ITextSegmentAdapter; >@@ -233,29 +231,23 @@ > return new Rectangle(x, y, width, height); > } > >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public boolean advanceLocator(GC gc, int wHint, Locator locator, >- public boolean advanceLocator(Font font, int wHint, Locator locator, >+ public boolean advanceLocator(GC gc, int wHint, Locator locator, > Hashtable objectTable, boolean computeHeightOnly) { >- Font gcFont = font; >- Font oldFont = null; >- if (fontId != null) { >-// oldFont = gc.getFont(); >- oldFont = gcFont; >- Font newFont = (Font) objectTable.get(fontId); >- if (newFont != null) >-// gc.setFont(newFont); >- gcFont = newFont; >- } >-// FontMetrics fm = gc.getFontMetrics(); >-// int lineHeight = fm.getHeight(); >- int lineHeight = Graphics.getCharHeight( gcFont ); >+ Font oldFont = null; >+ if (fontId != null) { >+ oldFont = gc.getFont(); >+ Font newFont = (Font) objectTable.get(fontId); >+ if (newFont != null) >+ gc.setFont(newFont); >+ } >+ FontMetrics fm = gc.getFontMetrics(); >+ int lineHeight = fm.getHeight(); >+ // RAP [if] fm.getLeading() is missing > int lineLeading = Math.round( lineHeight / LINE_LEADING_RATIO ); > boolean newLine = false; > > if (wHint == SWT.DEFAULT || !wrapAllowed) { >-// Point extent = gc.textExtent(text); >- Point extent = Graphics.stringExtent( gcFont, text ); >+ Point extent = gc.textExtent(text); > int totalExtent = locator.x+extent.x; > if (isSelectable()) > totalExtent+=1; >@@ -276,13 +268,13 @@ > locator.x += width; > locator.width = locator.indent + width; > locator.rowHeight = Math.max(locator.rowHeight, extent.y); >+ // RAP [if] fm.getLeading() is missing > // locator.leading = Math.max(locator.leading, fm.getLeading()); > locator.leading = Math.max(locator.leading, lineLeading); > return newLine; > } > >-// computeTextFragments(gc); >- computeTextFragments(gcFont); >+ computeTextFragments(gc); > > int width = 0; > Point lineExtent = new Point(0, 0); >@@ -298,6 +290,7 @@ > // overflow > int lineWidth = currentExtent; > locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y); >+ // RAP [if] fm.getLeading() is missing > // locator.leading = Math.max(locator.leading, fm.getLeading()); > locator.leading = Math.max(locator.leading, lineLeading); > if (computeHeightOnly) >@@ -320,11 +313,11 @@ > locator.x += lineWidth; > locator.width = width; > locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y); >+ // RAP [if] fm.getLeading() is missing > // locator.leading = Math.max(locator.leading, fm.getLeading()); > locator.leading = Math.max(locator.leading, lineLeading); > if (oldFont != null) { >-// gc.setFont(oldFont); >- gcFont = oldFont; >+ gc.setFont(oldFont); > } > return newLine; > } >@@ -340,14 +333,9 @@ > * @param lineHeight > * @param descent > */ >-// RAP [if] changed method signature and implementation to cope with missing GC >-// private void layoutWithoutWrapping(GC gc, int width, Locator locator, >-// boolean selected, FontMetrics fm, int lineHeight, int descent) { >- private void layoutWithoutWrapping(Font font, int width, Locator locator, >- boolean selected, int lineHeight, int descent) { >-// Point extent = gc.textExtent(text); >- Point extent = Graphics.stringExtent( font, text ); >- int lineLeading = Math.round( lineHeight / LINE_LEADING_RATIO ); >+ private void layoutWithoutWrapping(GC gc, int width, Locator locator, >+ boolean selected, FontMetrics fm, int lineHeight, int descent) { >+ Point extent = gc.textExtent(text); > int ewidth = extent.x; > if (isSelectable()) > ewidth += 1; >@@ -358,8 +346,10 @@ > locator.rowHeight = 0; > locator.rowCounter++; > } >+ // RAP [if] fm.getLeading() is missing > // int ly = locator.getBaseline(fm.getHeight() - fm.getLeading()); >- int ly = locator.getBaseline(Graphics.getCharHeight( font ) - lineLeading); >+ int lineLeading = Math.round( lineHeight / LINE_LEADING_RATIO ); >+ int ly = locator.getBaseline(fm.getHeight() - lineLeading); > //int lineY = ly + lineHeight - descent + 1; > Rectangle br = new Rectangle(locator.x, ly, ewidth, > lineHeight - descent + 3); >@@ -369,16 +359,13 @@ > locator.rowHeight = Math.max(locator.rowHeight, extent.y); > } > >-// RAP [if] changed method signature and implementation to cope with missing GC >-// protected int convertOffsetToStringIndex(GC gc, String s, int x, >- protected int convertOffsetToStringIndex(Font font, String s, int x, >+ protected int convertOffsetToStringIndex(GC gc, String s, int x, > int swidth, int selOffset) { > int index = s.length(); > while (index > 0 && x + swidth > selOffset) { > index--; > String ss = s.substring(0, index); >-// swidth = gc.textExtent(ss).x; >- swidth = Graphics.stringExtent( font, ss ).x; >+ swidth = gc.textExtent(ss).x; > } > return index; > } >@@ -479,35 +466,27 @@ > // } > // } > >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData) { >- public void computeSelection(Font font, Hashtable resourceTable, SelectionData selData) { >- Font gcFont = font; >- Font oldFont = null; >- >- if (fontId != null) { >-// oldFont = gc.getFont(); >- oldFont = gcFont; >- Font newFont = (Font) resourceTable.get(fontId); >- if (newFont != null) >-// gc.setFont(newFont); >- gcFont = newFont; >- } >+ public void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData) { >+ Font oldFont = null; >+ >+ if (fontId != null) { >+ oldFont = gc.getFont(); >+ Font newFont = (Font) resourceTable.get(fontId); >+ if (newFont != null) >+ gc.setFont(newFont); >+ } > > for (int i = 0; i < areaRectangles.size(); i++) { > AreaRectangle areaRectangle = (AreaRectangle) areaRectangles.get(i); > Rectangle rect = areaRectangle.rect; > String text = areaRectangle.getText(); >-// Point extent = gc.textExtent(text); >- Point extent = Graphics.stringExtent( gcFont, text ); >-// computeSelection(gc, text, extent.x, selData, >- computeSelection(gcFont, text, extent.x, selData, >+ Point extent = gc.textExtent(text); >+ computeSelection(gc, text, extent.x, selData, > rect); > } > // restore GC resources > if (oldFont != null) { >-// gc.setFont(oldFont); >- gcFont = oldFont; >+ gc.setFont(oldFont); > } > } > >@@ -582,9 +561,7 @@ > // } > // } > >-// RAP [if] changed method signature and implementation to cope with missing GC >-// private void computeSelection(GC gc, String s, int swidth, SelectionData selData, Rectangle bounds) { >- private void computeSelection(Font font, String s, int swidth, SelectionData selData, Rectangle bounds) { >+ private void computeSelection(GC gc, String s, int swidth, SelectionData selData, Rectangle bounds) { > int leftOffset = selData.getLeftOffset(bounds.height); > int rightOffset = selData.getRightOffset(bounds.height); > boolean firstRow = selData.isFirstSelectionRow(bounds.y, bounds.height); >@@ -595,13 +572,11 @@ > int sstop = -1; > > if (firstRow && bounds.x + swidth > leftOffset) { >-// sstart = convertOffsetToStringIndex(gc, s, bounds.x, swidth, >- sstart = convertOffsetToStringIndex(font, s, bounds.x, swidth, >+ sstart = convertOffsetToStringIndex(gc, s, bounds.x, swidth, > leftOffset); > } > if (lastRow && bounds.x + swidth > rightOffset) { >-// sstop = convertOffsetToStringIndex(gc, s, bounds.x, swidth, >- sstop = convertOffsetToStringIndex(font, s, bounds.x, swidth, >+ sstop = convertOffsetToStringIndex(gc, s, bounds.x, swidth, > rightOffset); > } > >@@ -671,39 +646,34 @@ > * java.util.Hashtable, boolean, > * org.eclipse.ui.internal.forms.widgets.SelectionData) > */ >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public void layout(GC gc, int width, Locator locator, >- public void layout(Font font, int width, Locator locator, >+ public void layout(GC gc, int width, Locator locator, > Hashtable resourceTable, boolean selected) { >- Font gcFont = font; >- Font oldFont = null; >- >- areaRectangles.clear(); >- >- if (fontId != null) { >-// oldFont = gc.getFont(); >- oldFont = gcFont; >- Font newFont = (Font) resourceTable.get(fontId); >- if (newFont != null) >-// gc.setFont(newFont); >- gcFont = newFont; >- } >-// FontMetrics fm = gc.getFontMetrics(); >-// int lineHeight = fm.getHeight(); >- int lineHeight = Graphics.getCharHeight( gcFont ); >- int lineLeading = Math.round( lineHeight / LINE_LEADING_RATIO ); >+ Font oldFont = null; >+ >+ areaRectangles.clear(); >+ >+ if (fontId != null) { >+ oldFont = gc.getFont(); >+ Font newFont = (Font) resourceTable.get(fontId); >+ if (newFont != null) >+ gc.setFont(newFont); >+ } >+ FontMetrics fm = gc.getFontMetrics(); >+ int lineHeight = fm.getHeight(); >+ // RAP [if] fm.getDescent() is missing >+// int descent = fm.getDescent(); > int descent = Math.round( lineHeight / LINE_DESCENT_RATIO ); >+ // RAP [if] fm.getLeading() is missing >+ int lineLeading = Math.round( lineHeight / LINE_LEADING_RATIO ); > > if (!wrapAllowed) { >-// layoutWithoutWrapping(gc, width, locator, selected, fm, lineHeight, >- layoutWithoutWrapping(gcFont, width, locator, selected, lineHeight, >+ layoutWithoutWrapping(gc, width, locator, selected, fm, lineHeight, > descent); > } else { > int lineStart = 0; > int lastLoc = 0; > Point lineExtent = new Point(0, 0); >-// computeTextFragments(gc); >- computeTextFragments(gcFont); >+ computeTextFragments(gc); > int rightEdge = width-locator.marginWidth; > for (int i = 0; i < textFragments.length; i++) { > TextFragment fragment = textFragments[i]; >@@ -715,6 +685,8 @@ > int lineWidth = locator.x + lineExtent.x; > if (isSelectable()) > lineWidth += 1; >+ // RAP [if] fm.getLeading() is missing >+// int ly = locator.getBaseline(lineHeight - fm.getLeading()); > int ly = locator.getBaseline(lineHeight - lineLeading); > Rectangle br = new Rectangle(isSelectable()? > locator.x - 1:locator.x, ly, >@@ -739,6 +711,8 @@ > lineExtent.y = Math.max(lineHeight, lineExtent.y); > } > //String lastLine = text.substring(lineStart, lastLoc); >+ // RAP [if] fm.getLeading() is missing >+// int ly = locator.getBaseline(lineHeight - fm.getLeading()); > int ly = locator.getBaseline(lineHeight - lineLeading); > int lastWidth = lineExtent.x; > if (isSelectable()) >@@ -752,14 +726,11 @@ > locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y); > } > if (oldFont != null) { >-// gc.setFont(oldFont); >- gcFont = oldFont; >+ gc.setFont(oldFont); > } > } > >-// RAP [if] changed method signature and implementation to cope with missing GC >-// private void computeTextFragments(GC gc) { >- private void computeTextFragments(Font font) { >+ private void computeTextFragments(GC gc) { > if (textFragments != null) > return; > ArrayList list = new ArrayList(); >@@ -770,8 +741,7 @@ > if (loc == 0) > continue; > String word = text.substring(cursor, loc); >-// Point extent = gc.textExtent(word); >- Point extent = Graphics.stringExtent( font, word ); >+ Point extent = gc.textExtent(word); > list.add(new TextFragment((short) loc, (short) extent.x)); > cursor = loc; > } >Index: src/org/eclipse/ui/internal/forms/widgets/Paragraph.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/Paragraph.java,v >retrieving revision 1.2 >diff -u -r1.2 Paragraph.java >--- src/org/eclipse/ui/internal/forms/widgets/Paragraph.java 16 Mar 2009 10:12:31 -0000 1.2 >+++ src/org/eclipse/ui/internal/forms/widgets/Paragraph.java 25 Feb 2010 13:25:33 -0000 >@@ -16,8 +16,6 @@ > import java.util.Vector; > > import org.eclipse.swt.graphics.*; >-// RAP [if] GC not supported >-//import org.eclipse.swt.graphics.GC; > import org.eclipse.ui.forms.HyperlinkSettings; > > /** >@@ -115,9 +113,7 @@ > addSegment(hs); > } > >-// RAP [if] changed method signature and implementation to cope with missing GC >-// protected void computeRowHeights(GC gc, int width, Locator loc, >- protected void computeRowHeights(Font font, int width, Locator loc, >+ protected void computeRowHeights(GC gc, int width, Locator loc, > int lineHeight, Hashtable resourceTable) { > ParagraphSegment[] segments = getSegments(); > // compute heights >@@ -128,17 +124,14 @@ > int innerWidth = width - loc.marginWidth*2; > for (int j = 0; j < segments.length; j++) { > ParagraphSegment segment = segments[j]; >-// segment.advanceLocator(gc, innerWidth, hloc, resourceTable, true); >- segment.advanceLocator(font, innerWidth, hloc, resourceTable, true); >+ segment.advanceLocator(gc, innerWidth, hloc, resourceTable, true); > } > hloc.collectHeights(); > loc.heights = heights; > loc.rowCounter = 0; > } > >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public void layout(GC gc, int width, Locator loc, int lineHeight, >- public void layout(Font font, int width, Locator loc, int lineHeight, >+ public void layout(GC gc, int width, Locator loc, int lineHeight, > Hashtable resourceTable, IHyperlinkSegment selectedLink) { > ParagraphSegment[] segments = getSegments(); > //int height; >@@ -150,15 +143,13 @@ > */ > // compute heights > if (loc.heights == null) >-// computeRowHeights(gc, width, loc, lineHeight, resourceTable); >- computeRowHeights(font, width, loc, lineHeight, resourceTable); >+ computeRowHeights(gc, width, loc, lineHeight, resourceTable); > for (int j = 0; j < segments.length; j++) { > ParagraphSegment segment = segments[j]; > boolean doSelect = false; > if (selectedLink != null && segment.equals(selectedLink)) > doSelect = true; >-// segment.layout(gc, width, loc, resourceTable, doSelect); >- segment.layout(font, width, loc, resourceTable, doSelect); >+ segment.layout(gc, width, loc, resourceTable, doSelect); > } > loc.heights = null; > loc.y += loc.rowHeight; >@@ -184,9 +175,7 @@ > // } > // } > >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public void computeSelection(GC gc, Hashtable resourceTable, IHyperlinkSegment selectedLink, >- public void computeSelection(Font font, Hashtable resourceTable, IHyperlinkSegment selectedLink, >+ public void computeSelection(GC gc, Hashtable resourceTable, IHyperlinkSegment selectedLink, > SelectionData selData) { > ParagraphSegment[] segments = getSegments(); > >@@ -195,8 +184,7 @@ > //boolean doSelect = false; > //if (selectedLink != null && segment.equals(selectedLink)) > //doSelect = true; >-// segment.computeSelection(gc, resourceTable, selData); >- segment.computeSelection(font, resourceTable, selData); >+ segment.computeSelection(gc, resourceTable, selData); > } > } > >Index: src/org/eclipse/ui/internal/forms/widgets/BulletParagraph.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/BulletParagraph.java,v >retrieving revision 1.2 >diff -u -r1.2 BulletParagraph.java >--- src/org/eclipse/ui/internal/forms/widgets/BulletParagraph.java 16 Mar 2009 10:12:31 -0000 1.2 >+++ src/org/eclipse/ui/internal/forms/widgets/BulletParagraph.java 25 Feb 2010 13:25:33 -0000 >@@ -13,12 +13,12 @@ > import java.util.Hashtable; > > import org.eclipse.rwt.Adaptable; >-import org.eclipse.rwt.graphics.Graphics; > // RAP [if] unnecessary > //import org.eclipse.swt.graphics.Color; >-// RAP [if] GC not supported >-//import org.eclipse.swt.graphics.GC; >-import org.eclipse.swt.graphics.*; >+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.ui.forms.internal.widgets.IBulletParagraphAdapter; > > public class BulletParagraph extends Paragraph implements Adaptable { >@@ -105,16 +105,11 @@ > return text; > } > >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public void layout(GC gc, int width, Locator loc, int lineHeight, >- public void layout(Font font, int width, Locator loc, int lineHeight, >+ public void layout(GC gc, int width, Locator loc, int lineHeight, > Hashtable resourceTable, IHyperlinkSegment selectedLink) { >-// computeRowHeights(gc, width, loc, lineHeight, resourceTable); >-// layoutBullet(gc, loc, lineHeight, resourceTable); >-// super.layout(gc, width, loc, lineHeight, resourceTable, selectedLink); >- computeRowHeights(font, width, loc, lineHeight, resourceTable); >- layoutBullet(font, loc, lineHeight, resourceTable); >- super.layout(font, width, loc, lineHeight, resourceTable, selectedLink); >+ computeRowHeights(gc, width, loc, lineHeight, resourceTable); >+ layoutBullet(gc, loc, lineHeight, resourceTable); >+ super.layout(gc, width, loc, lineHeight, resourceTable, selectedLink); > } > > // RAP [if] paint unnecessary >@@ -125,9 +120,7 @@ > // super.paint(gc, repaintRegion, resourceTable, selectedLink, selData); > // } > >-// RAP [if] changed method signature and implementation to cope with missing GC >-// private void layoutBullet(GC gc, Locator loc, int lineHeight, >- private void layoutBullet(Font font, Locator loc, int lineHeight, >+ private void layoutBullet(GC gc, Locator loc, int lineHeight, > Hashtable resourceTable) { > int x = loc.x - getIndent() + getBulletIndent(); > int rowHeight = ((int[]) loc.heights.get(0))[0]; >@@ -136,8 +129,7 @@ > bbounds = new Rectangle(x, y, CIRCLE_DIAM, CIRCLE_DIAM); > } else if (style == TEXT && text != null) { > //int height = gc.getFontMetrics().getHeight(); >-// Point textSize = gc.textExtent(text); >- Point textSize = Graphics.stringExtent( font, text ); >+ Point textSize = gc.textExtent(text); > bbounds = new Rectangle(x, loc.y, textSize.x, textSize.y); > } else if (style == IMAGE && text != null) { > Image image = (Image) resourceTable.get(text); >Index: src/org/eclipse/ui/internal/forms/widgets/ObjectSegment.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/ObjectSegment.java,v >retrieving revision 1.2 >diff -u -r1.2 ObjectSegment.java >--- src/org/eclipse/ui/internal/forms/widgets/ObjectSegment.java 16 Mar 2009 10:12:31 -0000 1.2 >+++ src/org/eclipse/ui/internal/forms/widgets/ObjectSegment.java 25 Feb 2010 13:25:33 -0000 >@@ -46,9 +46,7 @@ > > protected abstract Point getObjectSize(Hashtable resourceTable, int wHint); > >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public boolean advanceLocator(GC gc, int wHint, Locator loc, >- public boolean advanceLocator(Font font, int wHint, Locator loc, >+ public boolean advanceLocator(GC gc, int wHint, Locator loc, > Hashtable objectTable, boolean computeHeightOnly) { > Point objectSize = getObjectSize(objectTable, wHint); > int iwidth = 0; >@@ -115,9 +113,7 @@ > /* (non-Javadoc) > * @see org.eclipse.ui.internal.forms.widgets.ParagraphSegment#layout(org.eclipse.swt.graphics.GC, int, org.eclipse.ui.internal.forms.widgets.Locator, java.util.Hashtable, boolean, org.eclipse.ui.internal.forms.widgets.SelectionData) > */ >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public void layout(GC gc, int width, Locator loc, Hashtable resourceTable, >- public void layout(Font font, int width, Locator loc, Hashtable resourceTable, >+ public void layout(GC gc, int width, Locator loc, Hashtable resourceTable, > boolean selected) { > Point size = getObjectSize(resourceTable, width); > >@@ -149,9 +145,7 @@ > /* (non-Javadoc) > * @see org.eclipse.ui.internal.forms.widgets.ParagraphSegment#computeSelection(org.eclipse.swt.graphics.GC, java.util.Hashtable, boolean, org.eclipse.ui.internal.forms.widgets.SelectionData) > */ >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData) { >- public void computeSelection(Font font, Hashtable resourceTable, SelectionData selData) { >+ public void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData) { > // TODO we should add this to the selection > // if we want to support rich text > } >Index: src/org/eclipse/ui/internal/forms/widgets/TitleRegion.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/TitleRegion.java,v >retrieving revision 1.2 >diff -u -r1.2 TitleRegion.java >--- src/org/eclipse/ui/internal/forms/widgets/TitleRegion.java 25 Feb 2010 09:39:37 -0000 1.2 >+++ src/org/eclipse/ui/internal/forms/widgets/TitleRegion.java 25 Feb 2010 13:25:33 -0000 >@@ -28,8 +28,8 @@ > //import org.eclipse.swt.events.PaintListener; > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Font; >-//import org.eclipse.swt.graphics.FontMetrics; >-//import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.FontMetrics; >+import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; >@@ -462,14 +462,12 @@ > */ > public int getFontHeight() { > if (fontHeight == -1) { >- Font font = getFont(); >- // RAP [rh] Changes due to different API for text size determination >-// GC gc = new GC(getDisplay()); >-// gc.setFont(font); >-// FontMetrics fm = gc.getFontMetrics(); >-// fontHeight = fm.getHeight(); >-// gc.dispose(); >- fontHeight = Graphics.getCharHeight( font ); >+ Font font = getFont(); >+ GC gc = new GC(getDisplay()); >+ gc.setFont(font); >+ FontMetrics fm = gc.getFontMetrics(); >+ fontHeight = fm.getHeight(); >+ gc.dispose(); > } > return fontHeight; > } >@@ -481,14 +479,14 @@ > public int getFontBaselineHeight() { > if (fontBaselineHeight == -1) { > Font font = getFont(); >-// RAP [rh] Changed text size determination; inaccurate as baseline-height is >-// faked by font-height >-// GC gc = new GC(getDisplay()); >-// gc.setFont(font); >-// FontMetrics fm = gc.getFontMetrics(); >+ GC gc = new GC(getDisplay()); >+ gc.setFont(font); >+ FontMetrics fm = gc.getFontMetrics(); >+// RAP [if] FontMetrics#getDescent() is missing; inaccurate as baseline-height >+// is faked by font-height > // fontBaselineHeight = fm.getHeight() - fm.getDescent(); >-// gc.dispose(); >- fontBaselineHeight = Graphics.getCharHeight( font ); >+ fontBaselineHeight = fm.getHeight(); >+ gc.dispose(); > } > return fontBaselineHeight; > } >Index: src/org/eclipse/ui/internal/forms/widgets/ParagraphSegment.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/ParagraphSegment.java,v >retrieving revision 1.2 >diff -u -r1.2 ParagraphSegment.java >--- src/org/eclipse/ui/internal/forms/widgets/ParagraphSegment.java 16 Mar 2009 10:12:31 -0000 1.2 >+++ src/org/eclipse/ui/internal/forms/widgets/ParagraphSegment.java 25 Feb 2010 13:25:33 -0000 >@@ -13,8 +13,7 @@ > import java.util.Hashtable; > > import org.eclipse.swt.graphics.*; >-// RAP [if] GC not supported >-//import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.GC; > > /** > * @version 1.0 >@@ -30,9 +29,7 @@ > * @param computeHeightOnly > * @return <code>true</code> if text wrapped to the new line, <code>false</code> otherwise. > */ >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public abstract boolean advanceLocator(GC gc, int wHint, Locator loc, Hashtable objectTable, boolean computeHeightOnly); >- public abstract boolean advanceLocator(Font font, int wHint, Locator loc, Hashtable objectTable, boolean computeHeightOnly); >+ public abstract boolean advanceLocator(GC gc, int wHint, Locator loc, Hashtable objectTable, boolean computeHeightOnly); > /** > * Computes bounding rectangles and row heights of this segments. > * @param gc >@@ -41,9 +38,7 @@ > * @param resourceTable > * @param selected > */ >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public abstract void layout(GC gc, int width, Locator loc, Hashtable resourceTable, boolean selected); >- public abstract void layout(Font font, int width, Locator loc, Hashtable resourceTable, boolean selected); >+ public abstract void layout(GC gc, int width, Locator loc, Hashtable resourceTable, boolean selected); > // RAP [if] paint unnecessary > // /** > // * Paints this segment. >@@ -61,9 +56,7 @@ > * @param resourceTable > * @param selData > */ >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public abstract void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData); >- public abstract void computeSelection(Font font, Hashtable resourceTable, SelectionData selData); >+ public abstract void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData); > /** > * Tests if the coordinates are contained in one of the > * bounding rectangles of this segment. >Index: src/org/eclipse/ui/internal/forms/widgets/AggregateHyperlinkSegment.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/AggregateHyperlinkSegment.java,v >retrieving revision 1.3 >diff -u -r1.3 AggregateHyperlinkSegment.java >--- src/org/eclipse/ui/internal/forms/widgets/AggregateHyperlinkSegment.java 17 Mar 2009 18:34:14 -0000 1.3 >+++ src/org/eclipse/ui/internal/forms/widgets/AggregateHyperlinkSegment.java 25 Feb 2010 13:25:32 -0000 >@@ -16,9 +16,7 @@ > // RAP [if] unnecessary > //import org.eclipse.swt.graphics.Color; > import org.eclipse.rwt.Adaptable; >-import org.eclipse.swt.graphics.Font; >-// RAP [if] GC not supported >-//import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.ui.forms.internal.widgets.IAggregateHyperlinkSegmentAdapter; > >@@ -72,15 +70,12 @@ > * int, org.eclipse.ui.internal.forms.widgets.Locator, > * java.util.Hashtable, boolean) > */ >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public boolean advanceLocator(GC gc, int wHint, Locator loc, >- public boolean advanceLocator(Font font, int wHint, Locator loc, >+ public boolean advanceLocator(GC gc, int wHint, Locator loc, > Hashtable objectTable, boolean computeHeightOnly) { > boolean newLine = false; > for (int i = 0; i < segments.size(); i++) { > ParagraphSegment segment = (ParagraphSegment) segments.get(i); >-// if (segment.advanceLocator(gc, wHint, loc, objectTable, >- if (segment.advanceLocator(font, wHint, loc, objectTable, >+ if (segment.advanceLocator(gc, wHint, loc, objectTable, > computeHeightOnly)) > newLine = true; > } >@@ -189,14 +184,11 @@ > * java.util.Hashtable, boolean, > * org.eclipse.ui.internal.forms.widgets.SelectionData) > */ >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public void layout(GC gc, int width, Locator locator, >- public void layout(Font font, int width, Locator locator, >+ public void layout(GC gc, int width, Locator locator, > Hashtable resourceTable, boolean selected) { > for (int i = 0; i < segments.size(); i++) { > ParagraphSegment segment = (ParagraphSegment) segments.get(i); >-// segment.layout(gc, width, locator, resourceTable, selected); >- segment.layout(font, width, locator, resourceTable, selected); >+ segment.layout(gc, width, locator, resourceTable, selected); > } > } > >@@ -207,14 +199,11 @@ > * java.util.Hashtable, boolean, > * org.eclipse.ui.internal.forms.widgets.SelectionData) > */ >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public void computeSelection(GC gc, Hashtable resourceTable, >- public void computeSelection(Font font, Hashtable resourceTable, >+ public void computeSelection(GC gc, Hashtable resourceTable, > SelectionData selData) { > for (int i = 0; i < segments.size(); i++) { > ParagraphSegment segment = (ParagraphSegment) segments.get(i); >-// segment.computeSelection(gc, resourceTable, selData); >- segment.computeSelection(font, resourceTable, selData); >+ segment.computeSelection(gc, resourceTable, selData); > } > } > >Index: src/org/eclipse/ui/internal/forms/widgets/FormHeading.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormHeading.java,v >retrieving revision 1.9 >diff -u -r1.9 FormHeading.java >--- src/org/eclipse/ui/internal/forms/widgets/FormHeading.java 25 Feb 2010 09:39:37 -0000 1.9 >+++ src/org/eclipse/ui/internal/forms/widgets/FormHeading.java 25 Feb 2010 13:25:33 -0000 >@@ -20,7 +20,6 @@ > import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.IMessageProvider; > import org.eclipse.jface.resource.JFaceResources; >-import org.eclipse.rwt.graphics.Graphics; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.CLabel; > import org.eclipse.swt.dnd.DragSourceListener; >@@ -33,8 +32,8 @@ > //import org.eclipse.swt.events.MouseTrackListener; > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Font; >-//import org.eclipse.swt.graphics.FontMetrics; >-//import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.FontMetrics; >+import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; >@@ -388,13 +387,11 @@ > if (fontHeight == -1) { > Control c = getMessageControl(); > if (c == null) >- return 0; >- // RAP [rh] Changes due to different API for text size determination >-// GC gc = new GC(c.getDisplay()); >-// gc.setFont(c.getFont()); >-// fontHeight = gc.getFontMetrics().getHeight(); >-// gc.dispose(); >- fontHeight = Graphics.getCharHeight( c.getFont() ); >+ return 0; >+ GC gc = new GC(c.getDisplay()); >+ gc.setFont(c.getFont()); >+ fontHeight = gc.getFontMetrics().getHeight(); >+ gc.dispose(); > } > return fontHeight; > } >@@ -404,14 +401,14 @@ > Control c = getMessageControl(); > if (c == null) > return 0; >-// RAP [rh] Changed text size determination; inaccurate as baseline-height is >-// faked by font-height >-// GC gc = new GC(c.getDisplay()); >-// gc.setFont(c.getFont()); >-// FontMetrics fm = gc.getFontMetrics(); >+ GC gc = new GC(c.getDisplay()); >+ gc.setFont(c.getFont()); >+ FontMetrics fm = gc.getFontMetrics(); >+// RAP [if] FontMetrics#getDescent() is missing; inaccurate as baseline-height >+// is faked by font-height > // fontBaselineHeight = fm.getHeight() - fm.getDescent(); >-// gc.dispose(); >- fontBaselineHeight = Graphics.getCharHeight( getFont() ); >+ fontBaselineHeight = fm.getHeight(); >+ gc.dispose(); > } > return fontBaselineHeight; > } >Index: src/org/eclipse/ui/internal/forms/widgets/FormUtil.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormUtil.java,v >retrieving revision 1.2 >diff -u -r1.2 FormUtil.java >--- src/org/eclipse/ui/internal/forms/widgets/FormUtil.java 2 Apr 2009 07:51:44 -0000 1.2 >+++ src/org/eclipse/ui/internal/forms/widgets/FormUtil.java 25 Feb 2010 13:25:33 -0000 >@@ -11,11 +11,16 @@ > *******************************************************************************/ > package org.eclipse.ui.internal.forms.widgets; > >-import org.eclipse.rwt.graphics.Graphics; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.ScrolledComposite; > import org.eclipse.swt.events.MouseEvent; >-import org.eclipse.swt.graphics.*; >+//import org.eclipse.swt.graphics.Device; >+import org.eclipse.swt.graphics.FontMetrics; >+import org.eclipse.swt.graphics.GC; >+//import org.eclipse.swt.graphics.Image; >+//import org.eclipse.swt.graphics.ImageData; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.layout.GridData; > //import org.eclipse.swt.widgets.Combo; > import org.eclipse.swt.widgets.Composite; >@@ -24,7 +29,9 @@ > import org.eclipse.swt.widgets.Layout; > //import org.eclipse.swt.widgets.ScrollBar; > import org.eclipse.swt.widgets.Text; >-import org.eclipse.ui.forms.widgets.*; >+import org.eclipse.ui.forms.widgets.ColumnLayout; >+import org.eclipse.ui.forms.widgets.Form; >+import org.eclipse.ui.forms.widgets.FormText; > import org.eclipse.ui.forms.widgets.FormToolkit; > import org.eclipse.ui.forms.widgets.ILayoutExtension; > >@@ -92,34 +99,30 @@ > return text; > } > >-// RAP [rh] FormUtil#computeMinimumWidth unnecessary >-// public static int computeMinimumWidth(GC gc, String text) { >-// BreakIterator wb = BreakIterator.getWordInstance(); >-// wb.setText(text); >-// int last = 0; >-// >-// int width = 0; >-// >-// for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) { >-// String word = text.substring(last, loc); >-// Point extent = gc.textExtent(word); >-// width = Math.max(width, extent.x); >-// last = loc; >-// } >-// String lastWord = text.substring(last); >-// Point extent = gc.textExtent(lastWord); >-// width = Math.max(width, extent.x); >-// return width; >-// } >+ public static int computeMinimumWidth(GC gc, String text) { >+ BreakIterator wb = BreakIterator.getWordInstance(); >+ wb.setText(text); >+ int last = 0; >+ >+ int width = 0; >+ >+ for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) { >+ String word = text.substring(last, loc); >+ Point extent = gc.textExtent(word); >+ width = Math.max(width, extent.x); >+ last = loc; >+ } >+ String lastWord = text.substring(last); >+ Point extent = gc.textExtent(lastWord); >+ width = Math.max(width, extent.x); >+ return width; >+ } > >-// RAP [rh] changed method signature and implementation to cope with missing GC >-// public static Point computeWrapSize(GC gc, String text, int wHint) { >- public static Point computeWrapSize(Font font, String text, int wHint) { >+ public static Point computeWrapSize(GC gc, String text, int wHint) { > BreakIterator wb = BreakIterator.getWordInstance(); > wb.setText(text); >-// FontMetrics fm = gc.getFontMetrics(); >-// int lineHeight = fm.getHeight(); >- int lineHeight = Graphics.getCharHeight( font ); >+ FontMetrics fm = gc.getFontMetrics(); >+ int lineHeight = fm.getHeight(); > > int saved = 0; > int last = 0; >@@ -127,16 +130,14 @@ > int maxWidth = 0; > for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) { > String word = text.substring(saved, loc); >-// Point extent = gc.textExtent(word); >- Point extent = Graphics.stringExtent( font, word ); >+ Point extent = gc.textExtent(word); > if (extent.x > wHint) { > // overflow > saved = last; > height += extent.y; > // switch to current word so maxWidth will accommodate very long single words > word = text.substring(last, loc); >-// extent = gc.textExtent(word); >- extent = Graphics.stringExtent( font, word ); >+ extent = gc.textExtent(word); > } > maxWidth = Math.max(maxWidth, extent.x); > last = loc; >@@ -146,10 +147,8 @@ > * The recursive call proved to be the only thing that worked in all cases. Some attempts can be made > * to estimate the height, but the algorithm needs to be run again to be sure. > */ >-// if (maxWidth > wHint) >-// return computeWrapSize(gc, text, maxWidth); >- if (maxWidth > wHint) >- return computeWrapSize(font, text, maxWidth); >+ if (maxWidth > wHint) >+ return computeWrapSize(gc, text, maxWidth); > return new Point(maxWidth, height); > } > >Index: src/org/eclipse/ui/internal/forms/widgets/PixelConverter.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/PixelConverter.java,v >retrieving revision 1.1 >diff -u -r1.1 PixelConverter.java >--- src/org/eclipse/ui/internal/forms/widgets/PixelConverter.java 16 Apr 2008 09:44:27 -0000 1.1 >+++ src/org/eclipse/ui/internal/forms/widgets/PixelConverter.java 25 Feb 2010 13:25:33 -0000 >@@ -1,37 +1,37 @@ >-///******************************************************************************* >-// * Copyright (c) 2000, 2007 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: >-// * IBM Corporation - initial API and implementation >-// *******************************************************************************/ >-//package org.eclipse.ui.internal.forms.widgets; >-// >-//import org.eclipse.swt.graphics.FontMetrics; >-//import org.eclipse.swt.graphics.GC; >-//import org.eclipse.swt.widgets.Control; >-// >-//public class PixelConverter { >-// /** >-// * Number of horizontal dialog units per character, value <code>4</code>. >-// */ >-// private static final int HORIZONTAL_DIALOG_UNIT_PER_CHAR = 4; >-// >-// private FontMetrics fFontMetrics; >-// >-// public PixelConverter(Control control) { >-// GC gc = new GC(control); >-// gc.setFont(control.getFont()); >-// fFontMetrics = gc.getFontMetrics(); >-// gc.dispose(); >-// } >-// >-// public int convertHorizontalDLUsToPixels(int dlus) { >-// // round to the nearest pixel >-// return (fFontMetrics.getAverageCharWidth() * dlus + HORIZONTAL_DIALOG_UNIT_PER_CHAR / 2) >-// / HORIZONTAL_DIALOG_UNIT_PER_CHAR; >-// } >-//} >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 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: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.internal.forms.widgets; >+ >+import org.eclipse.swt.graphics.FontMetrics; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.widgets.Control; >+ >+public class PixelConverter { >+ /** >+ * Number of horizontal dialog units per character, value <code>4</code>. >+ */ >+ private static final int HORIZONTAL_DIALOG_UNIT_PER_CHAR = 4; >+ >+ private FontMetrics fFontMetrics; >+ >+ public PixelConverter(Control control) { >+ GC gc = new GC(control); >+ gc.setFont(control.getFont()); >+ fFontMetrics = gc.getFontMetrics(); >+ gc.dispose(); >+ } >+ >+ public int convertHorizontalDLUsToPixels(int dlus) { >+ // round to the nearest pixel >+ return (fFontMetrics.getAverageCharWidth() * dlus + HORIZONTAL_DIALOG_UNIT_PER_CHAR / 2) >+ / HORIZONTAL_DIALOG_UNIT_PER_CHAR; >+ } >+} >Index: src/org/eclipse/ui/internal/forms/widgets/BreakSegment.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/BreakSegment.java,v >retrieving revision 1.2 >diff -u -r1.2 BreakSegment.java >--- src/org/eclipse/ui/internal/forms/widgets/BreakSegment.java 16 Mar 2009 10:12:31 -0000 1.2 >+++ src/org/eclipse/ui/internal/forms/widgets/BreakSegment.java 25 Feb 2010 13:25:33 -0000 >@@ -12,11 +12,8 @@ > > import java.util.Hashtable; > >-//RAP [if] GC/FontMetrics not supported >-//import org.eclipse.swt.graphics.FontMetrics; >-//import org.eclipse.swt.graphics.GC; >-import org.eclipse.rwt.graphics.Graphics; >-import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.FontMetrics; >+import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Rectangle; > > /** >@@ -28,14 +25,11 @@ > /* (non-Javadoc) > * @see org.eclipse.ui.forms.internal.widgets.ParagraphSegment#advanceLocator(org.eclipse.swt.graphics.GC, int, org.eclipse.ui.forms.internal.widgets.Locator, java.util.Hashtable) > */ >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public boolean advanceLocator(GC gc, int wHint, Locator locator, >- public boolean advanceLocator(Font font, int wHint, Locator locator, >+ public boolean advanceLocator(GC gc, int wHint, Locator locator, > Hashtable objectTable, boolean computeHeightOnly) { > if (locator.rowHeight==0) { >-// FontMetrics fm = gc.getFontMetrics(); >-// locator.rowHeight = fm.getHeight(); >- locator.rowHeight = Graphics.getCharHeight( font ); >+ FontMetrics fm = gc.getFontMetrics(); >+ locator.rowHeight = fm.getHeight(); > } > if (computeHeightOnly) locator.collectHeights(); > locator.x = locator.indent; >@@ -58,15 +52,12 @@ > /* (non-Javadoc) > * @see org.eclipse.ui.internal.forms.widgets.ParagraphSegment#layout(org.eclipse.swt.graphics.GC, int, org.eclipse.ui.internal.forms.widgets.Locator, java.util.Hashtable, boolean, org.eclipse.ui.internal.forms.widgets.SelectionData) > */ >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public void layout(GC gc, int width, Locator locator, Hashtable ResourceTable, >- public void layout(Font font, int width, Locator locator, Hashtable ResourceTable, >+ public void layout(GC gc, int width, Locator locator, Hashtable ResourceTable, > boolean selected) { > locator.resetCaret(); > if (locator.rowHeight==0) { >-// FontMetrics fm = gc.getFontMetrics(); >-// locator.rowHeight = fm.getHeight(); >- locator.rowHeight = Graphics.getCharHeight( font ); >+ FontMetrics fm = gc.getFontMetrics(); >+ locator.rowHeight = fm.getHeight(); > } > locator.y += locator.rowHeight; > locator.rowHeight = 0; >@@ -76,9 +67,7 @@ > /* (non-Javadoc) > * @see org.eclipse.ui.internal.forms.widgets.ParagraphSegment#computeSelection(org.eclipse.swt.graphics.GC, java.util.Hashtable, boolean, org.eclipse.ui.internal.forms.widgets.SelectionData) > */ >-// RAP [if] changed method signature and implementation to cope with missing GC >-// public void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData) { >- public void computeSelection(Font font, Hashtable resourceTable, SelectionData selData) { >+ public void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData) { > selData.markNewLine(); > } > } >Index: src/org/eclipse/ui/forms/widgets/FormText.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/FormText.java,v >retrieving revision 1.3 >diff -u -r1.3 FormText.java >--- src/org/eclipse/ui/forms/widgets/FormText.java 25 Feb 2010 09:39:37 -0000 1.3 >+++ src/org/eclipse/ui/forms/widgets/FormText.java 25 Feb 2010 13:25:32 -0000 >@@ -16,7 +16,6 @@ > import java.util.Hashtable; > > import org.eclipse.core.runtime.ListenerList; >-import org.eclipse.rwt.graphics.Graphics; > import org.eclipse.swt.SWT; > import org.eclipse.swt.SWTException; > // RAP [if] accessibility not supported >@@ -52,9 +51,8 @@ > import org.eclipse.swt.events.SelectionListener; > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Font; >-// RAP [if] GC/FontMetrics not supported >-//import org.eclipse.swt.graphics.FontMetrics; >-//import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.FontMetrics; >+import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; >@@ -272,16 +270,14 @@ > return result; > } > >-// RAP [if] changed implementation to cope with missing GC > private Point computeTextSize(int wHint) { > Paragraph[] paragraphs = model.getParagraphs(); >-// GC gc = new GC(FormText.this); >-// gc.setFont(getFont()); >+ GC gc = new GC(FormText.this); >+ gc.setFont(getFont()); > Locator loc = new Locator(); > int width = wHint != SWT.DEFAULT ? wHint : 0; >-// FontMetrics fm = gc.getFontMetrics(); >-// int lineHeight = fm.getHeight(); >- int lineHeight = Graphics.getCharHeight( getFont() ); >+ FontMetrics fm = gc.getFontMetrics(); >+ int lineHeight = fm.getHeight(); > boolean selectableInTheLastRow = false; > for (int i = 0; i < paragraphs.length; i++) { > Paragraph p = paragraphs[i]; >@@ -297,8 +293,7 @@ > int pwidth = 0; > for (int j = 0; j < segments.length; j++) { > ParagraphSegment segment = segments[j]; >-// segment.advanceLocator(gc, wHint, loc, resourceTable, >- segment.advanceLocator(getFont(), wHint, loc, resourceTable, >+ segment.advanceLocator(gc, wHint, loc, resourceTable, > false); > if (wHint != SWT.DEFAULT) { > width = Math.max(width, loc.width); >@@ -316,13 +311,12 @@ > loc.y += lineHeight; > } > } >-// gc.dispose(); >+ gc.dispose(); > if (selectableInTheLastRow) > loc.y += 1; > return new Point(width, loc.y); > } > >-// RAP [if] changed implementation to cope with missing GC > protected void layout(Composite composite, boolean flushCache) { > // RAP [if] Instruct LCA to relayout the segments to the client > model.clearCache( null ); >@@ -339,20 +333,19 @@ > System.out.println("FormText layout ("+model.getAccessibleText()+"), carea="+carea); //$NON-NLS-1$ //$NON-NLS-2$ > } > >-// GC gc = new GC(composite); >-// gc.setFont(getFont()); >+ GC gc = new GC(composite); >+ gc.setFont(getFont()); > ensureBoldFontPresent(getFont()); >-// gc.setForeground(getForeground()); >-// gc.setBackground(getBackground()); >+ gc.setForeground(getForeground()); >+ gc.setBackground(getBackground()); > > Locator loc = new Locator(); > loc.marginWidth = marginWidth; > loc.marginHeight = marginHeight; > loc.x = marginWidth; > loc.y = marginHeight; >-// FontMetrics fm = gc.getFontMetrics(); >-// int lineHeight = fm.getHeight(); >- int lineHeight = Graphics.getCharHeight( getFont() ); >+ FontMetrics fm = gc.getFontMetrics(); >+ int lineHeight = fm.getHeight(); > > Paragraph[] paragraphs = model.getParagraphs(); > IHyperlinkSegment selectedLink = getSelectedLink(); >@@ -363,11 +356,10 @@ > loc.indent = p.getIndent(); > loc.resetCaret(); > loc.rowHeight = 0; >-// p.layout(gc, carea.width, loc, lineHeight, resourceTable, >- p.layout(getFont(), carea.width, loc, lineHeight, resourceTable, >+ p.layout(gc, carea.width, loc, lineHeight, resourceTable, > selectedLink); > } >-// gc.dispose(); >+ gc.dispose(); > if (DEBUG_TEXT) { > long stop = System.currentTimeMillis(); > System.out.println("FormText.layout: " + (stop - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ >@@ -1064,8 +1056,8 @@ > * @since 3.1 > */ > public void addSelectionListener(SelectionListener listener) { >+ checkWidget(); > // RAP [if] >-// checkWidget(); > // if (listener == null) { > // SWT.error(SWT.ERROR_NULL_ARGUMENT); > // } >@@ -1094,8 +1086,8 @@ > * @since 3.1 > */ > public void removeSelectionListener(SelectionListener listener) { >-// RAP [if] >-// checkWidget(); >+ checkWidget(); >+// RAP [if] > // if (listener == null) { > // SWT.error(SWT.ERROR_NULL_ARGUMENT); > // } >@@ -1350,7 +1342,7 @@ > } > > private void computeSelection() { >-// GC gc = new GC(this); >+ GC gc = new GC(this); > Paragraph[] paragraphs = model.getParagraphs(); > IHyperlinkSegment selectedLink = getSelectedLink(); > if (getDisplay().getFocusControl() != this) >@@ -1359,10 +1351,9 @@ > Paragraph p = paragraphs[i]; > if (i > 0) > selData.markNewLine(); >-// p.computeSelection(gc, resourceTable, selectedLink, selData); >- p.computeSelection(getFont(), resourceTable, selectedLink, selData); >+ p.computeSelection(gc, resourceTable, selectedLink, selData); > } >-// gc.dispose(); >+ gc.dispose(); > } > > void clearSelection() { >Index: src/org/eclipse/ui/forms/widgets/ExpandableComposite.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/ExpandableComposite.java,v >retrieving revision 1.6 >diff -u -r1.6 ExpandableComposite.java >--- src/org/eclipse/ui/forms/widgets/ExpandableComposite.java 18 Jan 2010 10:12:58 -0000 1.6 >+++ src/org/eclipse/ui/forms/widgets/ExpandableComposite.java 25 Feb 2010 13:25:32 -0000 >@@ -13,7 +13,6 @@ > > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.ListenerList; >-import org.eclipse.rwt.graphics.Graphics; > import org.eclipse.swt.SWT; > //import org.eclipse.swt.events.FocusEvent; > //import org.eclipse.swt.events.FocusListener; >@@ -25,8 +24,8 @@ > //import org.eclipse.swt.events.TraverseListener; > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Font; >-//import org.eclipse.swt.graphics.FontMetrics; >-//import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.FontMetrics; >+import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Canvas; >@@ -268,9 +267,7 @@ > if (twidth < size.x + IGAP + tcsize.x) { > twidth -= IGAP; > if (textLabel instanceof Label) >-// RAP [rh] Changes due to differences in text size determination >-// size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(twidth*(size.x/(float)(size.x+tcsize.x)))); >- size = FormUtil.computeWrapSize(textLabel.getFont(), ((Label)textLabel).getText(), Math.round(twidth*(size.x/(float)(size.x+tcsize.x)))); >+ size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(twidth*(size.x/(float)(size.x+tcsize.x)))); > else > size = textLabelCache.computeSize(Math.round(twidth*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT); > tcsize = textClientCache.computeSize(twidth-size.x, SWT.DEFAULT); >@@ -291,13 +288,11 @@ > } > } > if (toggle != null) { >-// RAP [rh] Chnages due to different text size calcuation >-// GC gc = new GC(ExpandableComposite.this); >-// gc.setFont(getFont()); >-// FontMetrics fm = gc.getFontMetrics(); >-// int textHeight = fm.getHeight(); >-// gc.dispose(); >- int textHeight = Graphics.getCharHeight( getFont() ); >+ GC gc = new GC(ExpandableComposite.this); >+ gc.setFont(getFont()); >+ FontMetrics fm = gc.getFontMetrics(); >+ int textHeight = fm.getHeight(); >+ gc.dispose(); > if (textClient != null > && (expansionStyle & LEFT_TEXT_CLIENT_ALIGNMENT) != 0) { > textHeight = Math.max(textHeight, tcsize.y); >@@ -412,9 +407,7 @@ > if (innertHint != SWT.DEFAULT && innertHint < size.x + IGAP + tcsize.x) { > innertHint -= IGAP; > if (textLabel instanceof Label) >-// RAP [rh] Changes due to differences in text size calculation >-// size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(innertHint*(size.x/(float)(size.x+tcsize.x)))); >- size = FormUtil.computeWrapSize(textLabel.getFont(), ((Label)textLabel).getText(), Math.round(innertHint*(size.x/(float)(size.x+tcsize.x)))); >+ size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(innertHint*(size.x/(float)(size.x+tcsize.x)))); > else > size = textLabelCache.computeSize(Math.round(innertHint*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT); > tcsize = textClientCache.computeSize(innertHint-size.x, SWT.DEFAULT);
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
Actions:
View
|
Diff
Attachments on
bug 303883
: 160183