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 97217 Details for
Bug 228397
Add font support for StyledCellLabelProvider
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch
228397.patch (text/plain), 5.54 KB, created by
Martin Aeschlimann
on 2008-04-23 09:14:34 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Martin Aeschlimann
Created:
2008-04-23 09:14:34 EDT
Size:
5.54 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface >Index: src/org/eclipse/jface/viewers/StyledCellLabelProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface/src/org/eclipse/jface/viewers/StyledCellLabelProvider.java,v >retrieving revision 1.2 >diff -u -r1.2 StyledCellLabelProvider.java >--- src/org/eclipse/jface/viewers/StyledCellLabelProvider.java 2 Apr 2008 10:02:41 -0000 1.2 >+++ src/org/eclipse/jface/viewers/StyledCellLabelProvider.java 23 Apr 2008 13:11:05 -0000 >@@ -37,14 +37,6 @@ > * {@link ViewerCell#setStyleRanges(StyleRange[])} to set style ranges > * on the label. > * </p> >- * <p> >- * The current version of the {@link StyledCellLabelProvider} will ignore all font settings on >- * {@link StyleRange}. Different fonts would make labels wider, and the native >- * selection drawing could not be reused. >- * </p> >- * >- * <p><strong>NOTE:</strong> This API is experimental and may be deleted or >- * changed before 3.4 is released.</p> > * > * @since 3.4 > */ >@@ -200,8 +192,6 @@ > int orientation = viewer.getControl().getStyle() & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT); > cachedTextLayout = new TextLayout(display); > cachedTextLayout.setOrientation(orientation); >- } else { >- cachedTextLayout.setText(""); // make sure no previous ranges are cleared //$NON-NLS-1$ > } > return cachedTextLayout; > } >@@ -215,37 +205,6 @@ > return (event.detail & SWT.FOCUSED) != 0 > && (this.style & NO_FOCUS) == 0; > } >- >- /** >- * Returns a {@link TextLayout} instance for the given cell >- * configured with the style ranges. The text layout instance is managed by >- * the label provider. Caller of the method must not dispose the text >- * layout. >- * >- * @param diplay >- * the current display >- * @param applyColors >- * if set, create colors in the result >- * @param cell >- * the viewer cell >- * @return a TextLayout instance >- */ >- private TextLayout getTextLayoutForInfo(Display display, ViewerCell cell, boolean applyColors) { >- TextLayout layout = getSharedTextLayout(display); >- >- layout.setText(cell.getText()); >- layout.setFont(cell.getFont()); // set also if null to clear previous usages >- >- StyleRange[] styleRanges = cell.getStyleRanges(); >- if (styleRanges != null) { // user didn't fill styled ranges >- for (int i = 0; i < styleRanges.length; i++) { >- StyleRange curr = prepareStyleRange(styleRanges[i], applyColors); >- layout.setStyle(curr, curr.start, curr.start + curr.length - 1); >- } >- } >- >- return layout; >- } > > /** > * Prepares the given style range before it is applied to the label. This method makes sure that >@@ -263,10 +222,8 @@ > protected StyleRange prepareStyleRange(StyleRange styleRange, boolean applyColors) { > // if no colors apply or font is set, create a clone and clear the > // colors and font >- if (styleRange.font != null || !applyColors >- && (styleRange.foreground != null || styleRange.background != null)) { >+ if (!applyColors && (styleRange.foreground != null || styleRange.background != null)) { > styleRange = (StyleRange) styleRange.clone(); >- styleRange.font = null; // ignore font settings until bug 168807 is resolved > if (!applyColors) { > styleRange.foreground = null; > styleRange.background = null; >@@ -305,7 +262,36 @@ > * java.lang.Object) > */ > protected void measure(Event event, Object element) { >- // use native measuring >+ if (!isOwnerDrawEnabled()) >+ return; >+ >+ ViewerCell cell= getViewerCell(event, element); >+ boolean applyColors = useColors(event); // always returns false >+ >+ TextLayout layout = getSharedTextLayout(event.display); >+ layout.setText(""); //$NON-NLS-1$ //make sure all previous ranges are cleared (see bug 226090) >+ >+ layout.setText(cell.getText()); >+ layout.setFont(cell.getFont()); // set also if null to clear previous usages >+ >+ int originalTextWidth= layout.getBounds().width; // text width without any styles >+ >+ boolean containsOtherFont= false; >+ >+ StyleRange[] styleRanges = cell.getStyleRanges(); >+ if (styleRanges != null) { // user didn't fill styled ranges >+ for (int i = 0; i < styleRanges.length; i++) { >+ StyleRange curr = prepareStyleRange(styleRanges[i], applyColors); >+ layout.setStyle(curr, curr.start, curr.start + curr.length - 1); >+ if (curr.font != null) { >+ containsOtherFont= true; >+ } >+ } >+ } >+ if (containsOtherFont) { >+ int textWidthDelta= layout.getBounds().width - originalTextWidth; >+ event.width += textWidthDelta; >+ } > } > > /* >@@ -353,10 +339,24 @@ > } > } > >- TextLayout textLayout = getTextLayoutForInfo(event.display, cell, applyColors); >- > Rectangle textBounds = cell.getTextBounds(); > if (textBounds != null) { >+ // fLayout has already been configured in 'measure()' >+ TextLayout textLayout= getSharedTextLayout(event.display); >+ >+ /* remove-begin if bug 228376 fixed */ >+ if (!applyColors) { >+ // need to remove colors for selected elements: measure doesn't provide that information, see bug 228376 >+ StyleRange[] styleRanges= cell.getStyleRanges(); >+ if (styleRanges != null) { >+ for (int i= 0; i < styleRanges.length; i++) { >+ StyleRange curr = prepareStyleRange(styleRanges[i], applyColors); >+ textLayout.setStyle(curr, curr.start, curr.start + curr.length - 1); >+ } >+ } >+ } >+ /* remove-end if bug 228376 fixed */ >+ > Rectangle layoutBounds = textLayout.getBounds(); > > int x = textBounds.x;
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 228397
:
97217
|
97238
|
97487
|
97488
|
118828
|
118939