I'm creating a simple "sticky note" application using GTK3. I implement the notes by wrapping a TextView in ScrolledWindow. I put them in Layout, so they are free to grow. I set min/max_content_width/height to control note size: I want it to start with some minimum size, then grow up to some point as text is entered into TextView and then once max size is reached, I want scrollbars to appear.
Minimum size works as expected, however ScolledWindow never grows - as soon as entered text stops fitting the initial area scrollbars appear. I tried setting vexpand/hexpand on both ScrolledWindow and TextView, but it didn't help.
There is little documentation on this, but as I understand it, max_content_width/height should do exactly what I need: expand ScrolledWindow up to some size, then show scrollbars. Is it some bug or am I missing something?
I'm using Rust, GTK 3.24.24 on Linux.
Without trying this, I think it should work to get the actual size of the Textview and setting it to the width request / height request of the ScrolledWindow, unless it is more than your max size. Probably by connecting to the TextView size changed signal.
To tell you the truth, I am not sure what max_content_width/height does in practical life.
Related
I have an NSTableView with only one column. When I change the Windows size, the TableView sticks to the Windows borders, as it should:
ScreenShot Small
However, when I expand the windows frame to much (for example, when using full screen) suddenly a second column appears:
ScreenShot FullScreen
I have no idea, why this is happening. I can't expand the first cell manually using this little resize indicator, it seems like the cell inside the tableview just wouldn't be able to grow more...
Here is a picture of the TableViews Attributes Inspector:
ScreenShot AttributeInspector
I didn't find any constraints or width settings that would explain this.
I would be really greatful for any kind of help.
Try changing the column sizing of tableView to Uniform in attributes inspector.
Also in your size inspector, check and adjust maximum width for the column depending on your window max allowable width.
I need a CodeMirror editor which starts with a certain width and then grows automatically to the right to match the maximum line length. I.e. roughly what CodeMirror does when height is set to auto, but with width.
Here's a self-contained example. The editor grows automatically along the y-axis fine, but not along the x-axis. By tweaking the CSS, I can either have a fixed width editor with a scrollbar, or one which fills the entire width of the browser, but not one which grows as you type. I assume overflow-x is relevant, but I don't understand how it interacts with other CSS size properties set on parent elements. I also tried setting that property on CodeMirror-scroll, but it didn't help.
I believe this can be done using CSS properties alone. In fact I have this behaviour in my application already, but growing to the left, rather than the right, but I don't understand why it happens, or how to reproduce it in a small example.
This question is essentially the same, but for the vertical scrollbar.
Simply add float:left to the CodeMirror div.
<div id="here" style="float:left"></div>
This is not something CodeMirror supports. You may be able to get something working by setting .CodeMirror's width to (-webkit-)fit-content, but there will likely be corner cases where this breaks the scrollbars or cursor placement.
In some of the applications, I have seen that we have an option to increase or decrease the fontSize of the text inside the label. But when we adjust it, the label automatically increases its height to contain it. How do we get the height of the label everytime we increase or decrease the fontsize?
And in some cases like news applications when it loads, there will be text only. But suddenly the image comes and the text readjusts itself to contain it. How does it do it by itself?
Someone plz help me...
CGSize textSize = [#"foobar" sizeWithFont:[UIFont boldSystemFontOfSize:18]];
Checkout NSString UIKit Additions. It has got a couple of these methods that let you ask a string how big it would be when rendered with a given font. With that information, you should be able to adjust things however you need with a little math.
Also, in some cases, it may be a web view. If this is the case, HTML/CSS sort of flows stuff around automatically in order to keep things tidy.
I'm using a TreeViewer within a jface WizardPage and the initial input into the tree causes the WizardPage to grow vertically so that it can show all of the tree's values. When expanding one of the tree's values, then the vertical scrollbar works as expected. I'd like to be able to set the tree's size initially so that it is fixed and the scrollbar is already shown when the WizardPage is first drawn, but doing this isn't particularly obvious to me - the setSize method on the TreeViewer's Tree doesn't seem to do anything.
Any help would be appreciated!
Just for the records for this old question:
We solve this problem in our applications by using an own layout manager which we can set fixed sizes for certain controls (with Swing we had done that by using component.setPreferredSize(size)). If no such fixed size is used, we calculate the preferred size of the control while performing the layout. This prevents making controls getting more and more space depending on the control's content when the user resizes the application window or dialog.
I'm working on a iPhone product page where some of the fields can be fairly long (product name etc.) I've created the page layout in IB, and use UILabels to show the text fields. For those long text labels I'd like the height of the label to scale and push the other labels further down. Is this possible using IB, or would I have to do everything in code? (Compute height and position of all the UILabels.)
I'm presently able to get the text in the labels to wrap and fill the available space, but I have to reserve space for this. When the label is only one line it leaves lots of unused space before the next label.
You will have to calculate the heights dynamically in code. I'm not sure what you're doing exactly, but you may want to start using a UITableView and return variable height cells. I wrote a blog post on how to do this at Cocoa Is My Girlfriend.
It did some searching for this same thing and as far as I can tell you have to manually resize and position the labels.
If you want to know how to dynamically resize a label, this is how I am doing it:
myLabel.frame = CGRectMake(227.0, 12.0, 22.0, 21.0);
I am happy to be wrong on this one, since I don't like having to do this either.