|
|
|
|
|
|
Re: Another step: Text cell added but.. [message #9528 is a reply to message #9483] |
Fri, 25 August 2006 20:19 |
Cal Messages: 70 Registered: July 2009 |
Member |
|
|
Override the computeSize() method in custom CTableTreeCell to get my text
control to resize along with column resize. Inserted this in both
Title&ChildArea branches for testing with SWT.SIMPLE and SWT.EXPAND
respectively. Added necessary private variables to CTableTreeCell to get
this to work (iBounds...etc.). This allowed me to get two solutions.
1. A simple cell that resized properly but couldnt expand to view children
2. An expanded cell that would resize properly, I think the problem with
this was the two toggles, it might cause confusion for the user, and 2., I
really want *one* focus area in a hierarchy. This gives 2, title & child.
3. If I remember correctly, the custom cell was aligned the toggle rather
than the titleArea text. I didnt try to fix that I figured it would be
easy to adjust. Getting an SWT.SIMPLE cell to display a tree hierarchy
would be the perfect solution....
If all else fails by Tuesday I'm going with the expanded cell solution.
from overriden computeSize()....
if(stepText != null)
{ TextLayout layout = new TextLayout(Display.getCurrent());
Rectangle cellRect = stepText.getBounds();
layout.setWidth(container.getColumn(2).getWidth());
layout.setText(stepText.getText());
int lineHeight = CTableTree.staticGC.stringExtent(stepText.getText()).y;
int lineCount = layout.getLineCount();
layout.dispose();
newHeight = lineHeight * (lineCount+1);
//+1 because narrow cells always seemed to be 1 line short for display
}
And here is my attempt at restructuring the tableTreeCell itself. In the
layout () method:
//SUPPOSE I POSITION MY CHILD AREA
//TO THE RIGHT OF THE TITLEAREA....
childArea.setBounds(
bounds.x+marginWidth+toggleBounds.width,
bounds.y/**REMOVE** titleHeight*/+childSpacing,
bounds.width-(/**ADD IN**/
titleWidth/**/+marginWidth+toggleBounds.width+rightChildInde nt),
bounds.height-(/*titleHeight*/+childSpacing+childSpacing));
And Here is my custom cell:
protected void createTitleContents(Composite contents, int style) {
//contents.setLayout COMMENTED AT SOME POINT
//SO THAT I COULD POSITION THE NEW COMPOSITE AS I LIKED.
//I'm not sure if I tried to reposition "contents" itself...
contents.setLayout(new FillLayout());
FillLayout layout = new FillLayout();
Composite composite = new Composite(contents, SWT.NONE);
composite.setLayout(layout);
mwidth = container.getColumn(2).getWidth();
stepText = new Text(composite, SWT.BORDER | SWT.WRAP | SWT.MULTI );
stepText.setText("This is a text box with multiple lines ");
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Another step: Text cell added but.. [message #564284 is a reply to message #9483] |
Fri, 25 August 2006 20:19 |
Cal Messages: 70 Registered: July 2009 |
Member |
|
|
Override the computeSize() method in custom CTableTreeCell to get my text
control to resize along with column resize. Inserted this in both
Title&ChildArea branches for testing with SWT.SIMPLE and SWT.EXPAND
respectively. Added necessary private variables to CTableTreeCell to get
this to work (iBounds...etc.). This allowed me to get two solutions.
1. A simple cell that resized properly but couldnt expand to view children
2. An expanded cell that would resize properly, I think the problem with
this was the two toggles, it might cause confusion for the user, and 2., I
really want *one* focus area in a hierarchy. This gives 2, title & child.
3. If I remember correctly, the custom cell was aligned the toggle rather
than the titleArea text. I didnt try to fix that I figured it would be
easy to adjust. Getting an SWT.SIMPLE cell to display a tree hierarchy
would be the perfect solution....
If all else fails by Tuesday I'm going with the expanded cell solution.
from overriden computeSize()....
if(stepText != null)
{ TextLayout layout = new TextLayout(Display.getCurrent());
Rectangle cellRect = stepText.getBounds();
layout.setWidth(container.getColumn(2).getWidth());
layout.setText(stepText.getText());
int lineHeight = CTableTree.staticGC.stringExtent(stepText.getText()).y;
int lineCount = layout.getLineCount();
layout.dispose();
newHeight = lineHeight * (lineCount+1);
//+1 because narrow cells always seemed to be 1 line short for display
}
And here is my attempt at restructuring the tableTreeCell itself. In the
layout () method:
//SUPPOSE I POSITION MY CHILD AREA
//TO THE RIGHT OF THE TITLEAREA....
childArea.setBounds(
bounds.x+marginWidth+toggleBounds.width,
bounds.y/**REMOVE** titleHeight*/+childSpacing,
bounds.width-(/**ADD IN**/
titleWidth/**/+marginWidth+toggleBounds.width+rightChildInde nt),
bounds.height-(/*titleHeight*/+childSpacing+childSpacing));
And Here is my custom cell:
protected void createTitleContents(Composite contents, int style) {
//contents.setLayout COMMENTED AT SOME POINT
//SO THAT I COULD POSITION THE NEW COMPOSITE AS I LIKED.
//I'm not sure if I tried to reposition "contents" itself...
contents.setLayout(new FillLayout());
FillLayout layout = new FillLayout();
Composite composite = new Composite(contents, SWT.NONE);
composite.setLayout(layout);
mwidth = container.getColumn(2).getWidth();
stepText = new Text(composite, SWT.BORDER | SWT.WRAP | SWT.MULTI );
stepText.setText("This is a text box with multiple lines ");
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|