Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340396 - Content in StyledText is not shown completely
Summary: Content in StyledText is not shown completely
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.5.1   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-17 23:29 EDT by Sun Yuechen CLA
Modified: 2019-11-08 04:38 EST (History)
1 user (show)

See Also:


Attachments
the screen shot (91.79 KB, image/png)
2011-03-17 23:31 EDT, Sun Yuechen CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sun Yuechen CLA 2011-03-17 23:29:24 EDT
I use a StyledText to show text in my application.
StyledText text = new StyledText(shell, SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);

And I set the font like:
FontData data = text.getFont().getFontData()[0];
Font font1 = new Font(text.getDisplay(),data.getName(),data.getHeight() *5 /4 , data.getStyle());
StyleRange[] styles = new StyleRange[1];
styles[0] = new StyleRange();
styles[0].font = font1;
styles[0].fontStyle = SWT.NORMAL;
int[] ranges = new int[]{0,text.getText().length()};
text.setStyleRanges(ranges,styles);

On Win7 or Vista, if the content of text is longer, some words will be covered by the vertical scroll bar. Please find the attachment.

Everything seems OK on XP.
Comment 1 Sun Yuechen CLA 2011-03-17 23:31:05 EDT
Created attachment 191483 [details]
the screen shot
Comment 2 Felipe Heidrich CLA 2011-03-24 09:51:48 EDT
Can you please attach a snippet that I can run here and reproduce the problem ?
It works for me with examples I have here.

Note: you should not set 
styles[0].font = font1;
styles[0].fontStyle = SWT.NORMAL;
at the same time, do not set fontStyle and font is being used.

and, if you always going to apply the same font for the entire text, just use StyledText#setFont().

Based on your example, you do not need a StyledText, just Text should be enough for what you are trying to do.
Comment 3 Sun Yuechen CLA 2011-03-29 21:51:35 EDT
package test;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Test {
public static void main(String[] args) {
Display dis = new Display();
Shell shell = new Shell(dis);
shell.setLayout(new FillLayout());

StyledText text = new StyledText(shell, SWT.BORDER | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.WRAP | SWT.READ_ONLY);  //set the style

text.setLeftMargin(10);  // left margin
text.setTopMargin(10);  //top margin
text.setLineSpacing(2); //line spacing

FontData data = new FontData();
text.setFont(new Font(dis, data));
text.append("http://pinyin.sogou.com/features/?v=5.2.0.5225&h=2B6168D8A8BFDBA33D1FE8C9D37C1F5B&r=5298_sogou_pinyin_51_5298&f=tcFeatures");
shell.setSize(250, 200);
shell.open();
while(!shell.isDisposed()){
if(!dis.readAndDispatch()){
dis.sleep();
}
}
dis.dispose();
}
}


Run it in Windows XP, it works, but not looks so well in Vista or WIN7.

I want to show the content in the StyledText with left and top margins, and want to show it with a bigger font.
Please check.
Comment 4 Lars Vogel CLA 2019-11-08 04:38:52 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant please remove the stalebug whiteboard tag.