wxWidget: How do change the size of the parent Sizer according to the size of the children sizers? - wxwidgets

this is a question about wxBoxSizer. I am implementing a custom wxWidget like collapsible pane.
The problem is: I have a wxBoxSizer (Sizer1), and I add another wxBoxSizer (Sizer2) as its child. If I change the size of Sizer2, How do I make Sizer1 update it's size, automatically or manually?
I have tried to call Fit() and Layout() on Sizer1 after I call SetSize() on Sizer2, but it doesn't change the size for Sizer1.
Please help, thank you!

Layout in wxWidgets always works from top to bottom and changing the size of a sub-window or sub-sizer will never change the size of the containing window on its own. If you do want this to happen, call Fit() on the parent window to tell it that should become as big as required by its children. Notice that calling it on the panel will still not be enough, you need to do it on the top level wxFrame or wxDialog itself, unless you have some free space in it which can be used to accommodate the increasing panel size.

wxBoxSizer1 already occupies the whole panel. So unless you change the size of the panel itself, the wxBoxSizer1 wont be resized. You might want to try another size as your main sizer such as wxFlexGridSizer. Here you have more choices for precise control.

Related

Add a scrollbar to yfiles.canvas.Control

I have a yfiles.canvas.Control, with some nodes inside. However, the number of nodes is getting bigger, and I need to add a scrollbar in order to vertically navigate through them, despite the reduced size in height.
How can I do this? I see that a ScrollBar class exists, but I don't know how to integrate it.
yFiles for HTML comes with scrollbars built in. You can customize their visibility, but by default they will be shown as soon as the content rectangle is larger than the visible area. Maybe calling updateContentRect is all that is missing in your code?

vb net: zoom in designer

I was searching google for a way to size the form and the controls with it and came across something that mentioned Control.scale. How do I use the control.scale method to size everything down to the way I want it.
Also, is there a way I can zoom the form out in the designer. I want to create a 1280X800 form, but my screen is 1024X768. I want to be able to zoom out to see the entire form wile still having it's size be 1280X800.
You can use tablelayout panel in order to fit your form in all resolutions.similary a property called anchor, which is also need to be assigned for the controls inside tablelayout panel according to your requirement [top,bottom,left,right] to achieve the same.
By the way you have to use percentage for setting the column's width and row's height in that.
Simply, this way of designing is called as fluid designing.
Table layout panel

NSPathControl and Auto Layout

I'm having some issues with NSPathControl and Auto Layout.
I want the path control to resize with the window. Which means, if I expand the width of the window, the NSPathControl should expand too. This works.
Now the problem is, that if I change the URL of the path control to a longer URL, the path control expands automatically. I don't want that. I want the path control width to stay the same, except when the user resizes the window.
I tried pinning the width it, but then I can't resize the window at all...
Also, when I don't pin the window of the path control, I can't make it smaller than the actual content of the sub controls, which represent the URL.
Hope that makes sense.
How can I fix this?
No need for subclassing. You can tell your view how much to resist compression. By default the priority is set to NSLayoutPriorityDefaultHigh. You are probably looking for NSLayoutPriorityDragThatCannotResizeWindow. You can set this in your XIB in the Size Inspector for the control or take a look at NSView's setContentCompressionResistancePriority:forOrientation:.
Solution
Sorry, I guess I asked to fast.
I got it working like this:
NSPathControl subclass
- (NSSize)intrinsicContentSize {
return NSMakeSize(NSViewNoInstrinsicMetric, NSViewNoInstrinsicMetric);
}

Controls change place and form size changes

I have designed a form in VB.NET. At design time I have placed two buttons on it.
When I run it, the form size looks smaller and the buttons I have placed at the bottom are not visible. Also the alignment of the text and picture box is also different from what I set at design time.
Computer at which I am running the form is using a different resolution.
change the properties (F4) of the buttons: in ANCHOR put Bottom, Right
your buttons will be tied to the bottom and the right of the screen, instead of to the top, left, which is the default.
Grab the screen size at runtime with
Dim screen as System.Windows.Forms.Screen = System.Windows.Forms.Screen.PrimaryScreen
and using a scale factor depending on the current size (in design), scale the window to match. Check the coordinates of the buttons by hand to make sure they are not outside of the visible portion of the window.
You may not have to leave this feature in if you can debug it to the point that you know the exact resolution that you need.

VB.NET: Scrollbar "button"?

I plan on using a scrollbar for, well, scrolling an image. The image is 200x500, however, the only visible area is 200x250.
So I set the max value to 250, and the min value to 0. The idea is that if I drag the scrollbar's button to the bottom, 250 pixels will have moved for the image, right?
But wait, the scrollbar's button is.... very small. And the scrollbar is actually pretty long. Is there a way to make the scrollbar's button longer?
How did you create this scrollbar? Is it a separate control all together, or it is a component of another control? I do know that scrollbars added separately act kinda funny at times.
What I would suggest is using the scollbars built into another container control, which should achieve the exact same effect.
Create a new panel control on your form, and name it. (I suggest something like panelPicture)
Position the panel where you want your picture to be.
Set the panel's size to 200x250.
Set the panel's "Autoscroll" property to True.
Put a PictureBox inside this panel, and name it. (I suggest something like picMyPicture.)
Set the PictureBox's position to 0, 0.
Set the PictureBox's size to 200x500 (or whatever is necessary).
Set the PictureBox's Image property as desired.
Now, the scrollbar should automatically appear on the picture, and it should look normal.
As a side note (which may or may not be relevant), users typically don't like having to scroll to see the rest of an image, so if you don't need the user to scroll down on the image for some definitive purpose (or because you don't know what the size of the image that will be handled is), I'd try and change the size of things on your form so scrolling will not be necessary.
I hope this helps!