Check if control is on screen - apache-flex

How do I check if a control/DisplayObject is on screen? This means it is displayed on screen so no scrolling needs to be done.
Example: I have several controls on a form. The size of the form exceeds the screen length/width. As a result I need scrollbars. How do I check if a control is on screen?

This is a less elegant solution, but if no one else answers, you can try to do this:
Check X and Y (or just Y if you are interested in height) of the component you want to verify is on-screen or off-screen.
Then compare that to the total height of the application or container of the component.

Related

ListView set height to show all items without scrolling

In my Xamarin.Forms app I have a ListView and I want to make the height big enough so that it shows all the items without having to scroll. How can I do this?
The point of ListView is to make sure that you can display all the data on any screen size, by using scrolling on a smaller screens that cannot fit all the data.
I am sorry but your question does not make sense. You cannot set a fixed / static height value that will work across different devices. Setting fixed UI size does not make sense on Xamarin.Forms in general unless you will distribute your application for a single device with a fixed screen size.

Preventing layouts from expanding beyond the window size

I'm trying to make my UI content expand nicely when the user resizes the window. I'm doing this in Qt Designer and learning about layouts and size policies.
Seems that everything is working fine for now: one layout stays within its maximum size, while another expands with the window resize, and they all stay above their minimum sizes. That's great and all, but the problem is that if I have a list with a lot of items, or if I am displaying a very large image, it will expand beyond the available window space and cause the window to be huge.
How can I specify something along the lines of "do not expand beyond the available window space"? I've played around with the size policies, but I couldn't get it to work. Is this something I need to set for the form itself rather than the layouts it contains?
I should specify this is the desired behavior: Display the widget as large as the available window, even if the widget content is too small. Expand/Shrink the widget to fill the window when the window is resized. Do not expand beyond the available window space. The widgets in question are 2 images (labels) and 1 list view.
I set the size policy to "ignored" for the respective widgets. That fixed it.
Or you can set the window maximum size.

Displaying an image and automatically re-size it

I can't quite figure out what the best way of displaying an image is in my particular case, so hopefully someone on here has a few tips.
I want to display an image that gets re-sized automatically to fit inside the space that is available. I currently do this by creating a class derived from QLabel that implements void resizeEvent(QResizeEvent*) where I do a QPixmap::scaled to re-size the image. The problem is that this only works when the widget is enlarged because the widget doesn't get a resizeEvent when I try to make the widget smaller. I guess that because I set the image to the same size as the widget, it isn't allowed to be sized smaller again? I guess I could try to create a smaller image therefor introducing a sort of "border" around the image which would perhaps allow re-size events to occur when making the area smaller. Any thoughts?
resizeEvent is sent whenever size is changed. It doesn't matter whether it is enlarged or not.
But you can set Policy and Max/Min size to constraint widget in shrinking/enlarging. So if you have your widget not getting resizeEvent AND it doesn't shrink either, then look at your size policy and min width/height. If it shrinks but you doesn't have resizeEvent then you have some error in you logic, I believe.
Alternatively you can use paintEvent for image painting and use QWidget::rect() for your widget width/height.
Try changing the size policy of the label to QSizePolicy::Preferred.
Have a look at size policies in general.

get TileGroup to autoresize columns

Not sure if I am doing this the best way but I want to create a mobile app that has a home menu screen much like the facebook iphone application(with out all the fancy button moves etc). The FB app has a 3X3 set of buttons that allow you to access things like news feed or friends.
In order to keep my layout consistent across different device screens I was trying to user the TileGroup with an image as a button for each tile.
but while I can specify the tilegroup to use 100% width and height and set the number of rows and columns to 3. It does not appear to autosize the height of the rows and columns to fit the screen. and it won't let me specify the with/height as a percentage.
so my question is firstly am I doing the right thing or is there a better way to lay it out. And if I am doing the right thing, then how do I get the columns to auto size
Thanks in advance
JaChNo
Try Using this. apply the following u may get what u needed
<s:TileGroup id="tile"
columnCount="3"
columnWidth="{tile.width / tile.columnCount}"
rowCount="3"
rowHeight="{tile.height / tile.rowCount}"
/>

Full screen mode in silverlight

Would it be possible to show an image in full screen mode using silverlight. I'm looking out for some thing like the full screen option of the flash video players.
You can set
Application.Current.Host.Content.IsFullScreen = true;
this has to be done from a mouse button event or a click, you can't force the user into full screen without some interaction on their part.
Then you'll need to scale the image. If it's in an element that scales automatically, like a Grid cell and the Grid resizes automatically (like if it's the root element on the page and the page doesn't have a width or height specified) then you're good, but otherwise you'll need to handle the Application.Current.Host.Content.FullScreenChanged event and either resize or apply a scale transform to the image or its container to make it fill the screen, and do the same when you go back to non full screen mode.
Set System.Windows.Interop.BrowserHost.IsFullScreen = true.

Resources