TableLayout heightPercentage: percentage of what? - codenameone

I need to create a Container with a layout of two rows, the second one twice the height of the first, and put the container in the south position of a BorderLayout. I tried to do this using a TableLayout with two rows and one column, setting the height percentages to 33 and 67, respectively. However the TableLayout filled the entire screen, not just the "South" area. The javadocs indicate that the height percentage refers to the "parent", which I assumed would be the container with the TableLayout. But, apparently, the parent in question will be the display.
My next attempt was to create a TableLayout with three rows and one column, giving the lower content a vertical span of 2. But the bottom rows just disappeared.
Is there a solution I overlooked?

There are two separate stages in layout, requesting the preferred size and dealing with assigned size.
During the request stage we don't have the final size of everything so this is "guesstimated" (which amazingly my spell checker didn't flag?).
As we do the layout we already have an assigned size based on that preferred size and then the percentage is calculated based on that assigned size.
If you place a table layout container in the center of a border layout it will get all available space and so the preferred size aspect of the calculation phase will become meaningless and then percentage will be of the space allocated to the component which is "all available space". Naturally scrolling brings this into a completely different dimension.

Related

Canvas layout and widget lingering with maxWidth/maxHeight

In this example, the green block has equal top and bottom layout properties. When the browser window gets resized, the block lingers to the top; that means, top offset remains constant, while bottom offset varies according to maxHeight widget property. (The block would also linger to the left should left layout property and maxWidth widget property be set.)
How do I reverse the behavior, so that the widget lingers to the bottom/right corner?
Add a composite as the root widget, give it a grid layout
add the widget you want to position fixed to the lower left corner of the screen to the composite, with row 1 and column 1
set the flex of row 0 and column 0 to 1
set a fixed height/width for rows 1 and 2 and columns 1 and 2
Width of column 1 and height of row 1 should be the dimensions you want for your widget.
Alternatively, you can play with row/column min/max height/width - see the grid layout API for all possibilities.
Yet another alternative is to use a canvas layout, where widgets stay where you put them, and their position or size is never recalculated automatically, and add a listener to the resize event of the container, in which you manually recompute everything. However, I never found a situation in which qooxdoo's containers and layouts didn't allow me to avoid this.
The demo you link to is a demo for what its name says - minimum and maximum sizes of widgets, not positioning. Controlling positioning in qooxdoo happens via layouts. (To some extent, layouts can also be used to specify rules for sizing, though.)

Dynamically size images in SQL Server Reporting Services

My goal is to have a list of items each item has an image beside it whose size is proportional to some number from a dataset. For example, a list of countries which includes an image of a person whose size is proportional to the population.
How can I dynamically specify the size of an image based on data from the dataset?
Two approaches which don't seem to work:
(1) specify an expression for the image size (that doesn't seem to fit).
(2) tell the image to fit container and set the size of the container to an expression.
I don't want to resort to storing 100 images of varying sizes.
Are there any better solutions?
The trick is to use the "Padding" values of a cell or an image. These can be set with an expression, and will be the white space around your image.
For example, set right padding to
=RowNumber("DataSet").ToString() &"pt"
and you will get an image that gets smaller on each row.
Hope this helps...

Silverlight: how to use a scroll viewer to wrap a list view without specifying height?

I have a control that has a list that varies in length greatly. This control appears in various places meaning that i cannot calculate its position and desired height easily.
Moreover all I want is for the scrollviewer to simply size itself according to its parent. currently it insists on sizing itself according to the content.
currently when i have a list that exceeds the height of the screen the whole control extends off the bottom and the scrollviewer shows no bar (because it has stretched to the heigth of the contents and so thinks it is not required).
I've not included code as the object graph is fairly deep.
What i am looking for is a set of conditions that would cause the scrollviewer to resize itself according to its content rather than its parent.
I have it working in a similar situation involving grids and datagrids, the unique part of this control is that there is a list containing controls.
Any ideas? I would prefer solutions that don't require use of code behind - but im really not in a position to be choosey.
Here are common reasons that come to mind that would allow a scroll viewer to size to its contents rather than to its "parent":-
It's placed on a Canvas or a StackPanel
It's assigned to a Grid row/column with it's Horizontal or Vertical alignment not set to Stretch and its content size is less than the size of the row or column.
Its ultimately upto the containing panel how it chooses to size a child element so its not really possible to dictate this completely from code inside the child.

WPF - automatically relocating children when parent resizes

I have a container whose size can change.
I will by dynamically creating instances of a user control and adding them to that container.
the size of the user control is fixed. what I want to do is, fit the most number of user controls in the container.
I think a good approach is to add the children horizontally until there is no more space to add another and then start another row.
Say, each row fits 3 children for a given width of the container. if it is expanded enough, it should automatically fit 4 children in a row.
Is there a container control (StackPanel Grid etc.) that I can use to host these user controls. What properties need to be changed.
On resizing the container, it should relocate the children so that the maximum children ae shown. Scrolling is okay as long as max are shown at any given time.
Is there a container that does this automatically? or should I manually create rows or panels or something and add n children to each - i.e., do it manually?
I think what you need is a WrapPanel.
There's a Panels Overview on the MSDN with a lot more information and links to specific types of Panel including the WrapPanel:
WrapPanel positions child elements in sequential position from left to right, breaking content to the next line at the edge of the containing box. Subsequent ordering happens sequentially from top to bottom or right to left, depending on the value of the Orientation property.
I think a good approach is to add the children horizontally until there is no more space to add another and then start another row.
This is exactly what a WrapPanel does.

How do I implement WPF layout if sizes of peer elements are not independent?

Imagine I have two WPF FrameworkElements that need to be laid out. One element contains text, and the other shows line numbers for the text.
The widths of these two elements are not independent. For example, if the text element gets narrower, then more lines may wrap, which increases the number of lines, which may cause the line number element to grow wider (e.g. if the number of lines goes from 99 to 100). But if the line number element grows wider, then there's less space for the text element, etc.
How do I implement layout in WPF if the sizes of my child elements need to be calculated in concert with one another? I am new to WPF layout, but it looks like a fundamental assumption of MeasureOverride is that an element's size can be calculated without regard to the sizes of peers.
Thanks for any help.
Sounds to me you need to implement the layout in the container. See http://www.wpftutorial.net/CustomLayoutPanel.html on how to implement your own layout panel. I think a Grid layout can do what you want. See http://www.wpftutorial.net/GridLayout.html

Resources