[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] SWT controls, Windows, flicking
|
- From: vkozhaev@xxxxxxxxx (VovkaMorkovka)
- Date: Fri, 9 May 2008 15:27:41 +0000 (UTC)
- Newsgroups: eclipse.platform.swt
- Organization: Eclipse
- User-agent: NewsPortal/0.36 (http://florian-amrhein.de/newsportal)
Hi All!
I have problem with filcking of SWT controls during resizing.
Please, see code bellow, as you can see I use StyledText but other text
widget are ficks to.
Does flicking of constrols is problem of SWT, or I can do thomething with
it?
Vladimir
p.s. Sorry, for my English
package testing_examples;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.ViewForm;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
public class LikeFilterpaneForm extends Composite {
public LikeFilterpaneForm(Composite parent, int style) {
super(parent, style);
this.setLayout(new FillLayout());
//
final SashForm mainForm = StandardLayoutTesting.createSashForm(this,
SWT.HORIZONTAL);
ViewForm emptyForm = new ViewForm(mainForm, SWT.NONE);
emptyForm.setBackground(Display.getCurrent()
.getSystemColor(SWT.COLOR_WHITE));
final SashForm formWithData = StandardLayoutTesting.createSashForm(
mainForm, SWT.HORIZONTAL);
mainForm.setWeights(new int[] { 20, 80 });
//
ViewForm viewFormForData = new ViewForm(formWithData, SWT.NONE);
viewFormForData.setBackground(Display.getCurrent().getSystemColor(
SWT.COLOR_WHITE));
// main form from adding text field
final SashForm mainTextFieldForm =
StandardLayoutTesting.createSashForm(
formWithData, SWT.VERTICAL);
mainTextFieldForm.setRedraw(true);
//
final SashForm upSashForm = StandardLayoutTesting.createSashForm(
mainTextFieldForm, SWT.HORIZONTAL);
final SashForm downSashForm = StandardLayoutTesting.createSashForm(
mainTextFieldForm, SWT.HORIZONTAL);
addGroupToSashForm(upSashForm, "Left group", 3);
addGroupToSashForm(upSashForm, "Right group",
StandardLayoutTesting.N_OF_ROWS_IN_BIG_COMPOSITE);
//
final ViewForm leftDownViewForm = new ViewForm(downSashForm, SWT.NONE);
Group leftDownGroup = new Group(leftDownViewForm, SWT.NONE);
leftDownGroup.setLayout(new FillLayout());
leftDownGroup.setText("This is label");
leftDownViewForm.setTopLeft(leftDownGroup);
leftDownViewForm.setBackground(Display.getCurrent().getSystemColor(
SWT.COLOR_WIDGET_BACKGROUND));
// leftDownGroup.pack();
this.createTestTable(leftDownGroup, 3, 10);
//
Group complexGroup = new Group(downSashForm, SWT.NONE | SWT.SMOOTH);
complexGroup.setText("Complex Group");
complexGroup.setLayout(new FillLayout());
//
TabFolder tabFolder = new TabFolder(complexGroup, SWT.NONE);
//
Group firstTab = new Group(tabFolder, SWT.NONE);
firstTab.setLayout(new FillLayout());
firstTab.setText("Aaa");
//
Group secondTab = new Group(tabFolder, SWT.NONE);
secondTab.setText("Bbb");
secondTab.setLayout(new FillLayout());
SashForm leftDownSashForm = new SashForm(firstTab, SWT.HORIZONTAL
| SWT.SMOOTH);
addGroupToSashForm(leftDownSashForm, "Left inside group", 3);
addGroupToSashForm(leftDownSashForm, "Right inside group", 3);
//
TabItem firstTI = new TabItem(tabFolder, SWT.NULL);
firstTI.setText("First tab");
firstTI.setControl(firstTab);
TabItem secondTI = new TabItem(tabFolder, SWT.NULL);
secondTI.setText("Second tab");
secondTI.setControl(secondTab);
//
firstTab.pack();
tabFolder.pack();
}
private Group addGroupToSashForm(SashForm sashForm, String groupTitle,
int numberOfRows) {
ViewForm viewForm = new ViewForm(sashForm, SWT.NONE);
viewForm.setToolTipText("View Form");
viewForm
setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
Group group = new Group(viewForm, SWT.NONE);
// group.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER,
// true, true));
group.setText(groupTitle);
group.setLayout(new GridLayout(1, false));
group.pack();
viewForm.setTopLeft(group);
//
fillComposite(group, numberOfRows);
viewForm.pack();
group.pack();
return group;
}
// Fill composite
private void fillComposite(Composite comp, int amountOfRows) {
for (int i = 0; i < amountOfRows; i++) {
Composite rowComposite = new Composite(comp, SWT.NONE);
rowComposite.setLayout(new FormLayout());
rowComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER,
true,
false));
MyTestWidget label = new MyTestWidget(rowComposite, 0, true);
FormData labelData = new FormData();
labelData.left = new FormAttachment(0, 5);
labelData.right = new FormAttachment(25, 0);
labelData.height = MyTestWidget.TEXT_HEIGHT;
label.setLayoutData(labelData);
//
MyTestWidget text = new MyTestWidget(rowComposite, 0, false);
FormData textData = new FormData();
textData.left = new FormAttachment(label, 5);
textData.right = new FormAttachment(100, -5);
textData.height = MyTestWidget.TEXT_HEIGHT;
text.setLayoutData(textData);
}
comp.pack();
}
private Table createTestTable(Composite parent, int numOfColumns,
int numOfRows) {
final Table table = new Table(parent, SWT.V_SCROLL | SWT.H_SCROLL);
table.setHeaderVisible(true);
for (int i = 0; i < numOfColumns; i++) {
TableColumn column = new TableColumn(table, SWT.NULL);
column.setText("Column " + i);
}
for (int i = 0; i < numOfRows; i++) {
TableItem item = new TableItem(table, SWT.NULL);
for (int j = 0; j < numOfRows; j++) {
item.setText(j, "row " + i);
}
}
for (int i = 0; i < table.getColumnCount(); i++) {
table.getColumn(i).pack();
}
return table;
}
}
package testing_examples;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.ViewForm;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
public class LikeInTestForm extends Composite {
SashForm topSashForm;
public LikeInTestForm(Composite parent, int style) {
super(parent, style);
this.setLayout(new FillLayout());
topSashForm = StandardLayoutTesting.createSashForm(this, SWT.HORIZONTAL
| SWT.BORDER);
ViewForm emptyViewForm = new ViewForm(topSashForm, SWT.FILL);
emptyViewForm.setBackground(Display.getCurrent().getSystemColor(
SWT.COLOR_WHITE));
Group gridLayoutGroup = new Group(topSashForm, SWT.NONE);
gridLayoutGroup.setText("Group with grid layout");
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
gridLayoutGroup.setLayout(gridLayout);
//
Group moveFromCenterGroup = new Group(gridLayoutGroup, SWT.FILL);
moveFromCenterGroup.setText("This is group from rext field");
moveFromCenterGroup.setLayoutData(new GridData(GridData.BEGINNING,
GridData.BEGINNING, true, true));
GridLayout insideGridLayout = new GridLayout();
insideGridLayout.numColumns = 1;
moveFromCenterGroup.setLayout(insideGridLayout);
fillComposite(moveFromCenterGroup,
StandardLayoutTesting.N_OF_ROWS_IN_BIG_COMPOSITE);
}
private void fillComposite(Composite comp, int amountOfRows) {
for (int i = 0; i < amountOfRows; i++) {
Composite rowComposite = new Composite(comp, SWT.NONE);
rowComposite.setLayout(new FormLayout());
rowComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER,
true, false));
MyTestWidget label = new MyTestWidget(rowComposite, 0, true);
FormData labelData = new FormData();
labelData.left = new FormAttachment(0, 5);
labelData.right = new FormAttachment(25, 0);
labelData.height = MyTestWidget.TEXT_HEIGHT;
label.setLayoutData(labelData);
//
MyTestWidget text = new MyTestWidget(rowComposite, 0, false);
FormData textData = new FormData();
textData.left = new FormAttachment(label, 5);
textData.right = new FormAttachment(100, -5);
textData.height = MyTestWidget.TEXT_HEIGHT;
text.setLayoutData(textData);
}
comp.pack();
}
}
package testing_examples;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
public class MyTestWidget extends Composite {
public static final int TEXT_HEIGHT=23;
public MyTestWidget(Composite parent, int style, boolean isItLabel) {
super(parent, SWT.NONE|SWT.NO_BACKGROUND);
this.setLayout(new FillLayout());
Control control;
if (isItLabel) {
control = new StyledText(this, SWT.READ_ONLY);
((StyledText) control).setText("Label");
control.setBackground(Display.getCurrent().getSystemColor(
SWT.COLOR_WIDGET_BACKGROUND));
} else {
control = new StyledText(this, SWT.BORDER);
((StyledText) control)
.setText("Textabcdefghigklmnopqrsttttttttttttt");
}
}
}
package testing_examples;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
public class StandardLayoutTesting {
public static int N_OF_ROWS_IN_BIG_COMPOSITE = 100;
public static final int WINDOW_WIDTH = 800;
public static final int WINDOW_HEIGHT = 600;
private static final boolean REPAINT_WHEN_DRAG_SASHFORM = true;
public static void main(String[] args) {
if (args.length > 0) {
try {
Integer rowsNum = Integer.valueOf("" + args[0]);
N_OF_ROWS_IN_BIG_COMPOSITE = rowsNum;
} catch (Exception e) {
}
}
Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
Composite simpleExample = new LikeInTestForm(tabFolder, SWT.NONE);
Composite complexExample = new LikeFilterpaneForm(tabFolder, SWT.NONE);
TabItem simpleTabItem = new TabItem(tabFolder, SWT.NONE);
simpleTabItem.setText("Simple example");
simpleTabItem.setControl(simpleExample);
//
TabItem complexTabItem = new TabItem(tabFolder, SWT.NONE);
complexTabItem.setText("Complex example");
complexTabItem.setControl(complexExample);
//
shell.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
public static SashForm createSashForm(Composite parent, int orientation)
{
SashForm sashForm;
if (REPAINT_WHEN_DRAG_SASHFORM) {
sashForm = new SashForm(parent, orientation | SWT.SMOOTH);
} else {
sashForm = new SashForm(parent, orientation);
}
return sashForm;
}
}