GXT LayoutContainer with scrollbar reports a client height value which includes the area below the scrollbar - gwt

I have this code which sets up a "main" container into which other modules of the application will go.
LayoutContainer c = new LayoutContainer();
c.setScrollMode(Scroll.ALWAYS);
parentContainer.add(c, <...>);
Then later on, I have the following as an event handler
pContainer = c; // pContainer is actually a parameter, but it has c's value
pContainer.removeAll();
pContainer.setLayout(new FitLayout());
LayoutContainer wrapperContainer = new LayoutContainer();
wrapperContainer.setLayout(new BorderLayout());
wrapperContainer.setBorders(false);
pContainer.add(wrapperContainer);
LayoutContainer west = pWestContentContainer;
BorderLayoutData westLayoutData = new BorderLayoutData(LayoutRegion.WEST);
westLayoutData.setSize(pWidth);
westLayoutData.setSplit(true);
wrapperContainer.add(west, westLayoutData);
LayoutContainer center = new LayoutContainer();
wrapperContainer.add(center, new BorderLayoutData(LayoutRegion.CENTER));
pCallback.withSplitContainer(center);
pContainer.layout();
So in effect, the container called 'west' here will be where the module's UI gets displayed. That module UI then does a simple rowlayout with two children. The botton child has RowData(1, 1) so it fills up all the available space.
My problem is that the c (parent) container reports a height and width value which includes the value underneath the scrollbars. What I would like is that the scrollbars show all the space excluding their own space.
This is a screenshot showing what I mean:
alt text http://img265.imageshack.us/img265/9206/scrollbar.png

Try adding padding equivalent to the scroll bars size 14px? on the container where the Scroll.Always is being applied

Related

How to implement text wrapping in group by column header layer in nattable

I want to implement text wrapping in heading titles.I also have group by layer added on top column header layer
Text wrapping is not working in group by header region with below configuration.How to implement text wrapping in this scenario
// Column header layer
this.colGrpModel = new ColumnGroupModel();
this.colHeaderLayr =
new ColumnHeaderLayer(this.colHeaderDataLayr, this.bodyLayr, this.bodyLayr.getSelectionLayer());
this.colGrpHeaderLayer =
new ColumnGroupHeaderLayer(this.colHeaderLayr,
this.bodyLayr.getSelectionLayer(), this.colGrpModel, false);
this.colGrpHeaderLayer.setCalculateHeight(true);
// Composite layer
CompositeLayer compositeGridLayer = new CompositeLayer(1, 2);
//Group by header layer
this.groupByHeaderLayer = new GroupByHeaderLayer(groupByModel, this.paramFilterGridLayer,
this.filterGridLayer.getColumnHeaderDataProvider());
compositeGridLayer.setChildLayer(GroupByHeaderLayer.GROUP_BY_REGION, this.groupByHeaderLayer, 0, 0);
compositeGridLayer.setChildLayer("Grid", this.filterGridLayer, 0, 1);
This is the groupBy configuration:
configRegstry.registerConfigAttribute(
GroupByConfigAttributes.GROUP_BY_CHILD_COUNT_PATTERN, "[{0}] - ({1})");
configRegstry.registerConfigAttribute(
GroupByConfigAttributes.GROUP_BY_HINT, "Drag columns here");
// To implement text wrapping in group by header region
configRegstry.registerConfigAttribute(
CellConfigAttributes.CELL_PAINTER,
new TextPainter(true, true, 2),
DisplayMode.NORMAL,
GroupByHeaderLayer.GROUP_BY_REGION);
Short answer: This is currently not supported.
Long answer:
You are misunderstanding several things.
Text wrapping means that a new line is added dynamically if there is not enough space in a cell. Since the GroupByHeader is actually one cell that spans the whole width, the cell width will never exceed to force text wrapping.
The TextPainter is a ICellPainter, so it is used to render cells.
The GroupByHeader (although a spanned cell) does not use the default cell painter. It uses the special GroupByHeaderPainter as it needs to inspect the GroupByModeland render fragments for each entry. That painter does currently not support line wrapping. And it does not use other ICellPainter internally.
That means, if you need to support line wrapping in the GroupByHeader you need to extend the GroupByHeaderPainter. As an open source project we like contributions. :)
If you want to add some sort of text wrapping in the GroupByHeader, you somehow need to specify when a text should be wrapped.

How to align bottom a PdfPCell spaning across more than one page?

I'm using iTextSharp version 4.1.6.16. I have a PdfPTable with two columns (1 row).
There is a lot of content in right cell so it spans across whole page and reaches next page.
In the left cell I only want to put some small PdfPTable at its bottom. To do it I use cell.VerticalAlignment = Element.ALIGN_BOTTOM; on the left cell of topmost table. This works well if the row is not bigger than a page.
If the row reaches next page, then the content of the left cell is indeed aligned to bottom, but to bottom of first page. So the right cell's content still continues on the next page, but the left cell is empty there (I tested with background color that it spans to next page also).
I tried setting KeepTogether on the inner table but it doesn't have any effect. I also thought about doing it with CellEvent but I couldn't find so far how to position IElement (not only Image or text) absolutely in the cell.
Is it a bug or designed behavior, that the content is aligned to the bottom of the first page the cell occupies? Is there a workaround or some better way to put content at the bottom of the cell no matter where it ends?
I've finally solved the issue with following workaround.
I created a CellEvent that gets PdfPTable and shifts it upwards as much as its content takes:
class BottomFix : IPdfPCellEvent
{
private readonly PdfPTable _content;
public BottomFix(PdfPTable content)
{
_content = content;
}
public void CellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases)
{
_content?.WriteSelectedRows(0, -1, position.Left, position.Top + _content.TotalHeight, canvases[PdfPTable.BACKGROUNDCANVAS]);
}
}
Then to my original two-row table I added second row, and I add there a cell of height equal to 0, where instead of putting content into, I use this CellEvent. The original left cell is left empty, so the content of next row is pushed onto it and it looks as it was originally there. I don't have borders in this table so they are not an issue, but it can also be solved by setting border of this 1px cell to none.
var cell = new PdfPCell();
var table = new PdfPTable(1) { /* some content etc... */ };
cell.FixedHeight = 0;
cell.CellEvent = new BottomFix(table);
// such prepared cell goes to top level table, second row, left column

GWT ScrollPanel get max size of children without scrolling

I was wondering is there any possibility to get the inner size of a
com.google.gwt.user.client.ui.ScrollPanel
object in GWT? I would like to create a children of the ScrollPanel that fits exactly into the empty space, without activating the scroll bars.
The ScrollPanel is initialized as follows:
[begin update after answer of #Abhijith Nagaraja]
public void onModuleLoad() {
Window.setMargin("0px");
TabLayoutPanel tabs = new TabLayoutPanel(30, Unit.PX);
//attach the tab panel to the body element
RootPanel.get(null).add(tabs);
//set the TabLayoutPanel to full size of the window.
String width = (Window.getClientWidth()) + "px";
String height = (Window.getClientHeight()) + "px";
tabs.setSize(width, height);
//create the scroll panel and activate the scroll bars
ScrollPanel scrollPanel = new ScrollPanel(new Button("a second button"));
scrollPanel.getElement().getStyle().setOverflowX(Overflow.SCROLL);
scrollPanel.getElement().getStyle().setOverflowY(Overflow.SCROLL);
//attach the scroll panel to the DOM
tabs.add(scrollPanel, "tab1");
System.out.println(scrollPanel.getOffsetWidth()); // --> 0
System.out.println(scrollPanel.getOffsetHeight()); // --> 0
}
[end update]
Reason: I want to initialize a dynamic visualization (which requires scrollbars at a later point in time) in such a way that, it looks nice and avoiding to add the ScrollPanel later.
ScrollPanel sp = new ScrollPanel();
...
int innerWidth = sp.getOffsetWidth()- sp.getElement().getScrollWidth();
...
NOTE: You can use the above code only if your scrollPanell is attached to the screen. In other words it should be rendered.
DOM.setStyleAttribute(scrollpanel.getElement(), "maxHeight", mMainHeight + "px");;

GWT: How do I create a TabsLayoutPanel with horizontal scroll bars?

I'm using GWT 2.4. I'm trying to create a tabs panel that has multiple tabs, so many that sometimes they exceed the allotted horizontal boundaries. How can I make a horizontal scroll bar appear? Here is how I'm creating my tabs panel now ...
tabsPanel = new TabLayoutPanel(BAR_HEIGHT_IN_EM, Style.Unit.EM);
final List<ScrollPanel> tabs = new ArrayList<ScrollPanel>();
for (final Node tabNode : documentNode.getChildren()) {
// Get the tab's child widgets and add them
// into the tab panel.
final ScrollPanel childpanel = new ScrollPanel();
childpanel.setHeight(SCROLL_PANEL_HEIGHT_PCT);
...
tabsPanel.add(childpanel, tabName);
} // for
tabsPanel.setWidth("100%");
tabsPanel.setHeight("100%");
As you can see, I tried width="100%", but no scroll panels appear that allow me to see the excess tabs.
Thanks, - Dave
There is no built in way to do this with the TabLayoutPanel, but looking at it's code it is possible to do this:
SimplePanel tab = (SimplePanel) getTabWidget(0).getParent();
FlowPanel tabBar = (FlowPanel) tab.getParent();
LayoutPanel container = (LayoutPanel) tabBar.getParent();
Element tabBarContainerLayer = container.getWidgetContainerElement(tabBar);
tabBarContainerLayer.getStyle().clearOverflowX();
DISCLAIMER: untested

smartgwt TabSet - how to use it for full screen (or percentage)

Given the code below, how is it possible to use a percentage to get width and hight
(when I do tabs.setWidth("80%") - it doesn't work).
any idea?
final TabSet tabs = new TabSet();
tabs.setWidth("80%"); //this doesn't work I use tabs.setHeight(600);
tabs.setHeight(600);
Add your TabSet to a Layoutmanager and do the sizing there (do not use size on the TabSet directly):
final TabSet tabs = new TabSet();
//TODO create some tabs
VLayout vLayout = new VLayout();
vLayout.addMember(tabs);
vLayout.setWidth("100%");
vLayout.setHeight("100%");
See examples how to use VLayout in the smartgwt showcase - layout . There are also other Layoutmanagers HLayout, VStack, HStack,...